From 004bb4cae02c78716060c285f90ae4e9d6988332 Mon Sep 17 00:00:00 2001 From: RogueException Date: Sat, 1 Apr 2017 13:54:39 -0300 Subject: [PATCH] Don't nullref in ShardedClient's OnLogout if already logged out. --- src/Discord.Net.WebSocket/DiscordShardedClient.cs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net.WebSocket/DiscordShardedClient.cs b/src/Discord.Net.WebSocket/DiscordShardedClient.cs index 1dc348c20..ab2cb9266 100644 --- a/src/Discord.Net.WebSocket/DiscordShardedClient.cs +++ b/src/Discord.Net.WebSocket/DiscordShardedClient.cs @@ -98,8 +98,11 @@ namespace Discord.WebSocket internal override async Task OnLogoutAsync() { //Assume threadsafe: already in a connection lock - for (int i = 0; i < _shards.Length; i++) - await _shards[i].LogoutAsync(); + if (_shards != null) + { + for (int i = 0; i < _shards.Length; i++) + await _shards[i].LogoutAsync(); + } CurrentUser = null; if (_automaticShards)