Add null checks to DiscordSocketClient's RemoveXXX functions
This commit is contained in:
@@ -359,10 +359,13 @@ namespace Discord.WebSocket
|
|||||||
internal SocketGuild RemoveGuild(ulong id)
|
internal SocketGuild RemoveGuild(ulong id)
|
||||||
{
|
{
|
||||||
var guild = DataStore.RemoveGuild(id);
|
var guild = DataStore.RemoveGuild(id);
|
||||||
foreach (var channel in guild.Channels)
|
if (guild != null)
|
||||||
guild.RemoveChannel(channel.Id);
|
{
|
||||||
foreach (var user in guild.Members)
|
foreach (var channel in guild.Channels)
|
||||||
guild.RemoveUser(user.Id);
|
guild.RemoveChannel(channel.Id);
|
||||||
|
foreach (var user in guild.Members)
|
||||||
|
guild.RemoveUser(user.Id);
|
||||||
|
}
|
||||||
return guild;
|
return guild;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,8 +404,11 @@ namespace Discord.WebSocket
|
|||||||
internal ISocketChannel RemovePrivateChannel(ulong id)
|
internal ISocketChannel RemovePrivateChannel(ulong id)
|
||||||
{
|
{
|
||||||
var channel = DataStore.RemoveChannel(id) as ISocketPrivateChannel;
|
var channel = DataStore.RemoveChannel(id) as ISocketPrivateChannel;
|
||||||
foreach (var recipient in channel.Recipients)
|
if (channel != null)
|
||||||
recipient.User.RemoveRef(this);
|
{
|
||||||
|
foreach (var recipient in channel.Recipients)
|
||||||
|
recipient.User.RemoveRef(this);
|
||||||
|
}
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user