From 726ef5fe65f991c5908d776c8908ee7ac8fc66b1 Mon Sep 17 00:00:00 2001 From: Cool-Man Date: Mon, 21 Nov 2022 07:49:25 -0700 Subject: [PATCH] Don't add private channels for dead DMs (if a user has been deleted, the channel shows up as having no recipients). --- src/Discord.Net.WebSocket/DiscordSocketClient.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index f2239010f..49d23fcbf 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -3006,6 +3006,10 @@ namespace Discord.WebSocket /// Unexpected channel type is created. internal ISocketPrivateChannel AddPrivateChannel(API.Channel model, ClientState state) { + // don't add dead DMs + if (! (model.Recipients.GetValueOrDefault()?.Any() ?? false)) + return null; + var channel = SocketChannel.CreatePrivate(this, state, model); state.AddChannel(channel as SocketChannel); return channel;