using Discord.WebSocket; using System.Collections.Generic; using System.Collections.Immutable; namespace Discord.Interactions { /// /// Represents a Web-Socket based context of an . /// public class SocketInteractionContext : IInteractionContext, IRouteMatchContainer where TInteraction : SocketInteraction { /// /// Gets the that the command will be executed with. /// public DiscordSocketClient Client { get; } /// /// Gets the the command originated from. /// /// /// Will be null if the command is from a DM Channel. /// public SocketGuild Guild { get; } /// /// Gets the the command originated from. /// public ISocketMessageChannel Channel { get; } /// /// Gets the who executed the command. /// public SocketUser User { get; } /// /// Gets the the command was recieved with. /// public TInteraction Interaction { get; } /// public IReadOnlyCollection SegmentMatches { get; private set; } /// /// Initializes a new . /// /// The underlying client. /// The underlying interaction. public SocketInteractionContext(DiscordSocketClient client, TInteraction interaction) { Client = client; Channel = interaction.Channel; Guild = (interaction.User as SocketGuildUser)?.Guild.Value; User = interaction.User; Interaction = interaction; } /// public void SetSegmentMatches(IEnumerable segmentMatches) => SegmentMatches = segmentMatches.ToImmutableArray(); //IRouteMatchContainer /// IEnumerable IRouteMatchContainer.SegmentMatches => SegmentMatches; // IInteractionContext /// IDiscordClient IInteractionContext.Client => Client; /// IGuild IInteractionContext.Guild => Guild; /// IMessageChannel IInteractionContext.Channel => Channel; /// IUser IInteractionContext.User => User; /// IDiscordInteraction IInteractionContext.Interaction => Interaction; } /// /// Represents a Web-Socket based context of an /// public class SocketInteractionContext : SocketInteractionContext { /// /// Initializes a new /// /// The underlying client /// The underlying interaction public SocketInteractionContext(DiscordSocketClient client, SocketInteraction interaction) : base(client, interaction) { } } }