Skip to content

Commit

Permalink
SocketInteraction is messed up (#2920)
Browse files Browse the repository at this point in the history
  • Loading branch information
Misha-133 committed Apr 28, 2024
1 parent f9086d3 commit 3054505
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ public abstract class SocketInteraction : SocketEntity<ulong>, IDiscordInteracti
/// </remarks>
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/>
public ulong? ChannelId { get; private set; }

Expand Down Expand Up @@ -165,6 +173,27 @@ internal virtual void Update(Model model)
: 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
};
}
}

/// <summary>
Expand Down

0 comments on commit 3054505

Please sign in to comment.