Skip to content

Commit

Permalink
Fix ShardedClient#GetShardFor null-case (#742)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
foxbot committed Jan 7, 2018
1 parent 5bbd9bb commit d5e9d6f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Discord.Net.WebSocket/DiscordShardedClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Discord.API;
using Discord.API;
using Discord.Rest;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -133,7 +133,7 @@ public int GetShardIdFor(IGuild guild)
private DiscordSocketClient GetShardFor(ulong guildId)
=> GetShard(GetShardIdFor(guildId));
public DiscordSocketClient GetShardFor(IGuild guild)
=> GetShardFor(guild.Id);
=> GetShardFor(guild?.Id ?? 0);

/// <inheritdoc />
public override async Task<RestApplication> GetApplicationInfoAsync(RequestOptions options = null)
Expand Down

0 comments on commit d5e9d6f

Please sign in to comment.