From d5e9d6f9c1e70c7b6c569615e491de1149324f56 Mon Sep 17 00:00:00 2001 From: Christopher F Date: Sat, 6 Jan 2018 22:54:50 -0500 Subject: [PATCH] Fix ShardedClient#GetShardFor null-case (#742) This resolves #742. Common cases for IGuild being null on access are DMs (since they do not belong to a guild) - this change resolves null guilds to shard zero, where DMs are also received. --- src/Discord.Net.WebSocket/DiscordShardedClient.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Discord.Net.WebSocket/DiscordShardedClient.cs b/src/Discord.Net.WebSocket/DiscordShardedClient.cs index e827909d9..4e99ae28d 100644 --- a/src/Discord.Net.WebSocket/DiscordShardedClient.cs +++ b/src/Discord.Net.WebSocket/DiscordShardedClient.cs @@ -1,4 +1,4 @@ -using Discord.API; +using Discord.API; using Discord.Rest; using System; using System.Collections.Generic; @@ -133,7 +133,7 @@ namespace Discord.WebSocket private DiscordSocketClient GetShardFor(ulong guildId) => GetShard(GetShardIdFor(guildId)); public DiscordSocketClient GetShardFor(IGuild guild) - => GetShardFor(guild.Id); + => GetShardFor(guild?.Id ?? 0); /// public override async Task GetApplicationInfoAsync(RequestOptions options = null)