From be6abe1161bcb9c2a7d25f8b3636ca600661fdb9 Mon Sep 17 00:00:00 2001 From: Christopher F Date: Mon, 24 Apr 2017 21:53:41 -0400 Subject: [PATCH] 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). --- src/Discord.Net.WebSocket/DiscordSocketClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index e0bf08e71..a8543f108 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -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;