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 + }; + } } ///