From 7db38f32bb481d790362ea6a5bc998045373113a Mon Sep 17 00:00:00 2001 From: AntiTcb Date: Tue, 16 May 2017 20:04:25 -0400 Subject: [PATCH] Attach/Remove DMChannel to SocketGlobalUser.DMChannel property --- src/Discord.Net.WebSocket/DiscordSocketClient.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/Discord.Net.WebSocket/DiscordSocketClient.cs b/src/Discord.Net.WebSocket/DiscordSocketClient.cs index 4476b78c4..d42df7b55 100644 --- a/src/Discord.Net.WebSocket/DiscordSocketClient.cs +++ b/src/Discord.Net.WebSocket/DiscordSocketClient.cs @@ -1634,6 +1634,9 @@ namespace Discord.WebSocket { var channel = SocketChannel.CreatePrivate(this, state, model); state.AddChannel(channel as SocketChannel); + if (channel is SocketDMChannel dm) + dm.Recipient.GlobalUser.DMChannel = dm; + return channel; } internal ISocketPrivateChannel RemovePrivateChannel(ulong id) @@ -1641,6 +1644,9 @@ namespace Discord.WebSocket var channel = State.RemoveChannel(id) as ISocketPrivateChannel; if (channel != null) { + if (channel is SocketDMChannel dmChannel) + dmChannel.Recipient.GlobalUser.DMChannel = null; + foreach (var recipient in channel.Recipients) recipient.GlobalUser.RemoveRef(this); }