Throw when the client isn't logged in instead of connected
The previous commit prevents any connections, since the initial presence update is sent while the client is still in the 'connecting' state, rather than the 'connected' state. This resolves the original issue by preventing a nullref, and the more recent issue by only throwing a detailed exception when the CurrentUser is null (the client isn't logged in).
This commit is contained in:
@@ -359,8 +359,8 @@ namespace Discord.WebSocket
|
||||
}
|
||||
private async Task SendStatusAsync()
|
||||
{
|
||||
if (ConnectionState != ConnectionState.Connected)
|
||||
throw new InvalidOperationException("Presence data cannot be sent while the client is disconnected.");
|
||||
if (CurrentUser == null)
|
||||
throw new InvalidOperationException("Presence data cannot be sent before the client has logged in.");
|
||||
var game = Game;
|
||||
var status = Status;
|
||||
var statusSince = _statusSince;
|
||||
|
||||
Reference in New Issue
Block a user