Browse Source

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).
tags/1.0.0-rc2
Christopher F 8 years ago
parent
commit
be6abe1161
1 changed files with 2 additions and 2 deletions
  1. +2
    -2
      src/Discord.Net.WebSocket/DiscordSocketClient.cs

+ 2
- 2
src/Discord.Net.WebSocket/DiscordSocketClient.cs View File

@@ -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;


Loading…
Cancel
Save