SocketInteraction is messed up (#2920)

This commit is contained in:
Mihail Gribkov
2024-04-28 19:51:48 +03:00
committed by GitHub
parent f9086d3a2c
commit 3054505d4b

View File

@@ -26,6 +26,14 @@ namespace Discord.WebSocket
/// </remarks> /// </remarks>
public ISocketMessageChannel Channel { get; private set; } public ISocketMessageChannel Channel { get; private set; }
/// <summary>
/// Gets the channel this interaction was used in.
/// </summary>
/// <remarks>
/// This property can contain a partial channel object. <see langword="null"/> if no channel was passed with the interaction.
/// </remarks>
public IMessageChannel InteractionChannel { get; private set; }
/// <inheritdoc/> /// <inheritdoc/>
public ulong? ChannelId { get; private set; } public ulong? ChannelId { get; private set; }
@@ -165,6 +173,27 @@ namespace Discord.WebSocket
: null; : null;
Permissions = new GuildPermissions((ulong)model.ApplicationPermissions); 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
};
}
} }
/// <summary> /// <summary>