From 3054505d4b50370d6c11545dcf356ef9363d6903 Mon Sep 17 00:00:00 2001 From: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com> Date: Sun, 28 Apr 2024 19:51:48 +0300 Subject: [PATCH] `SocketInteraction` is messed up (#2920) --- .../Entities/Interaction/SocketInteraction.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs index 54a00b8a..ae2ac198 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs @@ -26,6 +26,14 @@ namespace Discord.WebSocket /// public ISocketMessageChannel Channel { get; private set; } + /// + /// Gets the channel this interaction was used in. + /// + /// + /// This property can contain a partial channel object. if no channel was passed with the interaction. + /// + public IMessageChannel InteractionChannel { get; private set; } + /// public ulong? ChannelId { get; private set; } @@ -165,6 +173,27 @@ namespace Discord.WebSocket : null; Permissions = new GuildPermissions((ulong)model.ApplicationPermissions); + + InteractionChannel = Channel; + if (model.Channel.IsSpecified && InteractionChannel is null) + { + InteractionChannel = model.Channel.Value.Type switch + { + ChannelType.News or + ChannelType.Text or + ChannelType.Voice or + ChannelType.Stage or + ChannelType.NewsThread or + ChannelType.PrivateThread or + ChannelType.PublicThread or + ChannelType.Media or + ChannelType.Forum + => RestChannel.Create(Discord, model.Channel.Value) as IMessageChannel, + ChannelType.DM => RestDMChannel.Create(Discord, model.Channel.Value), + ChannelType.Group => RestGroupChannel.Create(Discord, model.Channel.Value), + _ => null + }; + } } ///