Added status checks to a several properties of DiscordClient.

This commit is contained in:
RogueException
2015-12-01 14:55:13 -04:00
parent bdf89c91c4
commit 736e5ed268
3 changed files with 7 additions and 4 deletions

View File

@@ -66,7 +66,7 @@ namespace Discord
} }
/// <summary> Returns a collection of all servers this client is a member of. </summary> /// <summary> Returns a collection of all servers this client is a member of. </summary>
public IEnumerable<Channel> PrivateChannels => _channels.PrivateChannels; public IEnumerable<Channel> PrivateChannels { get { CheckReady(); return _channels.PrivateChannels; } }
internal Channels Channels => _channels; internal Channels Channels => _channels;
private readonly Channels _channels; private readonly Channels _channels;

View File

@@ -56,7 +56,7 @@ namespace Discord
} }
/// <summary> Returns a collection of all servers this client is a member of. </summary> /// <summary> Returns a collection of all servers this client is a member of. </summary>
public IEnumerable<Server> AllServers => _servers; public IEnumerable<Server> AllServers { get { CheckReady(); return _servers; } }
internal Servers Servers => _servers; internal Servers Servers => _servers;
private readonly Servers _servers; private readonly Servers _servers;

View File

@@ -134,10 +134,10 @@ namespace Discord
private User _privateUser; private User _privateUser;
/// <summary> Returns information about the currently logged-in account. </summary> /// <summary> Returns information about the currently logged-in account. </summary>
public GlobalUser CurrentUser => _privateUser.Global; public GlobalUser CurrentUser { get { CheckReady(); return _privateUser.Global; } }
/// <summary> Returns a collection of all unique users this client can currently see. </summary> /// <summary> Returns a collection of all unique users this client can currently see. </summary>
public IEnumerable<GlobalUser> AllUsers => _globalUsers; public IEnumerable<GlobalUser> AllUsers { get { CheckReady(); return _globalUsers; } }
internal GlobalUsers GlobalUsers => _globalUsers; internal GlobalUsers GlobalUsers => _globalUsers;
private readonly GlobalUsers _globalUsers; private readonly GlobalUsers _globalUsers;
@@ -146,6 +146,9 @@ namespace Discord
public GlobalUser GetUser(long userId) public GlobalUser GetUser(long userId)
{ {
if (userId <= 0) throw new ArgumentOutOfRangeException(nameof(userId));
CheckReady();
return _globalUsers[userId]; return _globalUsers[userId];
} }
/// <summary> Returns the user with the specified id, along with their server-specific data, or null if none was found. </summary> /// <summary> Returns the user with the specified id, along with their server-specific data, or null if none was found. </summary>