From 2cb0a010d63e94c7f6a65fa2315578bd17bf95ae Mon Sep 17 00:00:00 2001 From: Cenk Ergen <57065323+Cenngo@users.noreply.github.com> Date: Fri, 19 Nov 2021 10:37:56 +0300 Subject: [PATCH] Interaction Specific Interfaces (#283) * added interaction specific interfaces * fix build error * implement change requests --- .../IMessageCommandInteraction.cs | 13 ++++++ .../IMessageCommandInteractionData.cs | 13 ++++++ .../ContextMenus/IUserCommandInteraction.cs | 13 ++++++ .../IUserCommandInteractionData.cs | 13 ++++++ .../IComponentInteraction.cs | 18 +++++++++ .../IComponentInteractionData.cs | 25 ++++++++++++ .../SlashCommands/IAutocompleteInteraction.cs | 13 ++++++ .../IAutocompleteInteractionData.cs | 40 +++++++++++++++++++ .../SlashCommands/ISlashCommandInteraction.cs | 13 ++++++ .../MessageCommands/RestMessageCommand.cs | 6 ++- .../MessageCommands/RestMessageCommandData.cs | 6 ++- .../UserCommands/RestUserCommand.cs | 6 ++- .../UserCommands/RestUserCommandData.cs | 6 ++- .../MessageComponents/RestMessageComponent.cs | 9 ++++- .../RestMessageComponentData.cs | 2 +- .../RestAutocompleteInteraction.cs | 7 ++-- .../RestAutocompleteInteractionData.cs | 2 +- .../SlashCommands/RestSlashCommand.cs | 6 ++- .../MessageCommands/SocketMessageCommand.cs | 8 +++- .../SocketMessageCommandData.cs | 6 ++- .../UserCommands/SocketUserCommand.cs | 8 +++- .../UserCommands/SocketUserCommandData.cs | 6 ++- .../SocketMessageComponent.cs | 11 ++++- .../SocketMessageComponentData.cs | 2 +- .../SocketAutocompleteInteraction.cs | 8 +++- .../SocketAutocompleteInteractionData.cs | 2 +- .../SlashCommands/SocketSlashCommand.cs | 8 +++- 27 files changed, 246 insertions(+), 24 deletions(-) create mode 100644 src/Discord.Net.Core/Entities/Interactions/ContextMenus/IMessageCommandInteraction.cs create mode 100644 src/Discord.Net.Core/Entities/Interactions/ContextMenus/IMessageCommandInteractionData.cs create mode 100644 src/Discord.Net.Core/Entities/Interactions/ContextMenus/IUserCommandInteraction.cs create mode 100644 src/Discord.Net.Core/Entities/Interactions/ContextMenus/IUserCommandInteractionData.cs create mode 100644 src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteraction.cs create mode 100644 src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteractionData.cs create mode 100644 src/Discord.Net.Core/Entities/Interactions/SlashCommands/IAutocompleteInteraction.cs create mode 100644 src/Discord.Net.Core/Entities/Interactions/SlashCommands/IAutocompleteInteractionData.cs create mode 100644 src/Discord.Net.Core/Entities/Interactions/SlashCommands/ISlashCommandInteraction.cs diff --git a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/IMessageCommandInteraction.cs b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/IMessageCommandInteraction.cs new file mode 100644 index 000000000..b1b331e8b --- /dev/null +++ b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/IMessageCommandInteraction.cs @@ -0,0 +1,13 @@ +namespace Discord +{ + /// + /// Represents a Message Command interaction. + /// + public interface IMessageCommandInteraction : IDiscordInteraction + { + /// + /// Gets the data associated with this interaction. + /// + new IMessageCommandInteractionData Data { get; } + } +} diff --git a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/IMessageCommandInteractionData.cs b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/IMessageCommandInteractionData.cs new file mode 100644 index 000000000..311eef2d6 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/IMessageCommandInteractionData.cs @@ -0,0 +1,13 @@ +namespace Discord +{ + /// + /// Represents the data tied with the interaction. + /// + public interface IMessageCommandInteractionData : IApplicationCommandInteractionData + { + /// + /// Gets the message associated with this message command. + /// + IMessage Message { get; } + } +} diff --git a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/IUserCommandInteraction.cs b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/IUserCommandInteraction.cs new file mode 100644 index 000000000..f7cfd67f0 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/IUserCommandInteraction.cs @@ -0,0 +1,13 @@ +namespace Discord +{ + /// + /// Represents a User Command interaction. + /// + public interface IUserCommandInteraction : IDiscordInteraction + { + /// + /// Gets the data associated with this interaction. + /// + new IUserCommandInteractionData Data { get; } + } +} diff --git a/src/Discord.Net.Core/Entities/Interactions/ContextMenus/IUserCommandInteractionData.cs b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/IUserCommandInteractionData.cs new file mode 100644 index 000000000..36e482ec9 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Interactions/ContextMenus/IUserCommandInteractionData.cs @@ -0,0 +1,13 @@ +namespace Discord +{ + /// + /// Represents the data tied with the interaction. + /// + public interface IUserCommandInteractionData : IApplicationCommandInteractionData + { + /// + /// Gets the user who this command targets. + /// + IUser User { get; } + } +} diff --git a/src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteraction.cs b/src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteraction.cs new file mode 100644 index 000000000..2a46e8f18 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteraction.cs @@ -0,0 +1,18 @@ +namespace Discord +{ + /// + /// Represents an interaction type for Message Components. + /// + public interface IComponentInteraction : IDiscordInteraction + { + /// + /// Gets the data received with this interaction, contains the button that was clicked. + /// + new IComponentInteractionData Data { get; } + + /// + /// Gets the message that contained the trigger for this interaction. + /// + IUserMessage Message { get; } + } +} diff --git a/src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteractionData.cs b/src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteractionData.cs new file mode 100644 index 000000000..99b9b6f6c --- /dev/null +++ b/src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteractionData.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; + +namespace Discord +{ + /// + /// Represents the data sent with the . + /// + public interface IComponentInteractionData : IDiscordInteractionData + { + /// + /// Gets the components Custom Id that was clicked. + /// + string CustomId { get; } + + /// + /// Gets the type of the component clicked. + /// + ComponentType Type { get; } + + /// + /// Gets the value(s) of a interaction response. + /// + IReadOnlyCollection Values { get; } + } +} diff --git a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/IAutocompleteInteraction.cs b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/IAutocompleteInteraction.cs new file mode 100644 index 000000000..bb5343d84 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/IAutocompleteInteraction.cs @@ -0,0 +1,13 @@ +namespace Discord +{ + /// + /// Represents a . + /// + public interface IAutocompleteInteraction : IDiscordInteraction + { + /// + /// Gets the autocomplete data of this interaction. + /// + new IAutocompleteInteractionData Data { get; } + } +} diff --git a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/IAutocompleteInteractionData.cs b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/IAutocompleteInteractionData.cs new file mode 100644 index 000000000..e6d1e9fae --- /dev/null +++ b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/IAutocompleteInteractionData.cs @@ -0,0 +1,40 @@ +using System.Collections.Generic; + +namespace Discord +{ + /// + /// Represents data for a slash commands autocomplete interaction. + /// + public interface IAutocompleteInteractionData : IDiscordInteractionData + { + /// + /// Gets the name of the invoked command. + /// + string CommandName { get; } + + /// + /// Gets the id of the invoked command. + /// + ulong CommandId { get; } + + /// + /// Gets the type of the invoked command. + /// + ApplicationCommandType Type { get; } + + /// + /// Gets the version of the invoked command. + /// + ulong Version { get; } + + /// + /// Gets the current autocomplete option that is actively being filled out. + /// + AutocompleteOption Current { get; } + + /// + /// Gets a collection of all the other options the executing users has filled out. + /// + IReadOnlyCollection Options { get; } + } +} diff --git a/src/Discord.Net.Core/Entities/Interactions/SlashCommands/ISlashCommandInteraction.cs b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/ISlashCommandInteraction.cs new file mode 100644 index 000000000..556182987 --- /dev/null +++ b/src/Discord.Net.Core/Entities/Interactions/SlashCommands/ISlashCommandInteraction.cs @@ -0,0 +1,13 @@ +namespace Discord +{ + /// + /// Represents a slash command interaction. + /// + public interface ISlashCommandInteraction : IDiscordInteraction + { + /// + /// Gets the data associated with this interaction. + /// + new IApplicationCommandInteractionData Data { get; } + } +} diff --git a/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/MessageCommands/RestMessageCommand.cs b/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/MessageCommands/RestMessageCommand.cs index e19dabf53..c587ac881 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/MessageCommands/RestMessageCommand.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/MessageCommands/RestMessageCommand.cs @@ -7,7 +7,7 @@ namespace Discord.Rest /// /// Represents a REST-based message command interaction. /// - public class RestMessageCommand : RestCommandBase, IDiscordInteraction + public class RestMessageCommand : RestCommandBase, IMessageCommandInteraction, IDiscordInteraction { /// /// The data associated with this interaction. @@ -38,6 +38,8 @@ namespace Discord.Rest Data = await RestMessageCommandData.CreateAsync(client, dataModel, Guild, Channel).ConfigureAwait(false); } - IDiscordInteractionData IDiscordInteraction.Data => Data; + //IMessageCommandInteraction + /// + IMessageCommandInteractionData IMessageCommandInteraction.Data => Data; } } diff --git a/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/MessageCommands/RestMessageCommandData.cs b/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/MessageCommands/RestMessageCommandData.cs index 3ced005f6..ee528bc65 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/MessageCommands/RestMessageCommandData.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/MessageCommands/RestMessageCommandData.cs @@ -10,7 +10,7 @@ namespace Discord.Rest /// /// Represents the data for a . /// - public class RestMessageCommandData : RestCommandBaseData, IDiscordInteractionData + public class RestMessageCommandData : RestCommandBaseData, IMessageCommandInteractionData, IDiscordInteractionData { /// /// Gets the message associated with this message command. @@ -34,5 +34,9 @@ namespace Discord.Rest await entity.UpdateAsync(client, model, guild, channel).ConfigureAwait(false); return entity; } + + //IMessageCommandInteractionData + /// + IMessage IMessageCommandInteractionData.Message => Message; } } diff --git a/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/UserCommands/RestUserCommand.cs b/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/UserCommands/RestUserCommand.cs index d3ff22b21..52466debf 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/UserCommands/RestUserCommand.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/UserCommands/RestUserCommand.cs @@ -11,7 +11,7 @@ namespace Discord.Rest /// /// Represents a REST-based user command. /// - internal class RestUserCommand : RestCommandBase, IDiscordInteraction + internal class RestUserCommand : RestCommandBase, IUserCommandInteraction, IDiscordInteraction { /// /// Gets the data associated with this interaction. @@ -41,6 +41,8 @@ namespace Discord.Rest Data = await RestUserCommandData.CreateAsync(client, dataModel, Guild, Channel).ConfigureAwait(false); } - IDiscordInteractionData IDiscordInteraction.Data => Data; + //IUserCommandInteractionData + /// + IUserCommandInteractionData IUserCommandInteraction.Data => Data; } } diff --git a/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/UserCommands/RestUserCommandData.cs b/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/UserCommands/RestUserCommandData.cs index dc9301dfc..5ceec6bca 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/UserCommands/RestUserCommandData.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/ContextMenuCommands/UserCommands/RestUserCommandData.cs @@ -8,7 +8,7 @@ namespace Discord.Rest /// /// Represents the data for a . /// - public class RestUserCommandData : RestCommandBaseData, IDiscordInteractionData + public class RestUserCommandData : RestCommandBaseData, IUserCommandInteractionData, IDiscordInteractionData { /// /// Gets the user who this command targets. @@ -32,5 +32,9 @@ namespace Discord.Rest await entity.UpdateAsync(client, model, guild, channel).ConfigureAwait(false); return entity; } + + //IUserCommandInteractionData + /// + IUser IUserCommandInteractionData.User => Member; } } diff --git a/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs b/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs index 513f67201..da843468b 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs @@ -13,7 +13,7 @@ namespace Discord.Rest /// /// Represents a REST-based message component. /// - internal class RestMessageComponent : RestInteraction, IDiscordInteraction + internal class RestMessageComponent : RestInteraction, IComponentInteraction, IDiscordInteraction { /// /// Gets the data received with this interaction, contains the button that was clicked. @@ -442,6 +442,11 @@ namespace Discord.Rest return SerializePayload(response); } - IDiscordInteractionData IDiscordInteraction.Data => Data; + //IComponentInteraction + /// + IComponentInteractionData IComponentInteraction.Data => Data; + + /// + IUserMessage IComponentInteraction.Message => Message; } } diff --git a/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponentData.cs b/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponentData.cs index f8aa24937..e865c208c 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponentData.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponentData.cs @@ -10,7 +10,7 @@ namespace Discord.Rest /// /// Represents data for a . /// - public class RestMessageComponentData : IDiscordInteractionData + public class RestMessageComponentData : IComponentInteractionData, IDiscordInteractionData { /// /// Gets the components Custom Id that was clicked. diff --git a/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestAutocompleteInteraction.cs b/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestAutocompleteInteraction.cs index d3e99fcb9..3b879cd4e 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestAutocompleteInteraction.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestAutocompleteInteraction.cs @@ -12,7 +12,7 @@ namespace Discord.Rest /// /// Represents a REST-based autocomplete interaction. /// - public class RestAutocompleteInteraction : RestInteraction, IDiscordInteraction + public class RestAutocompleteInteraction : RestInteraction, IAutocompleteInteraction, IDiscordInteraction { /// /// Gets the autocomplete data of this interaction. @@ -128,7 +128,8 @@ namespace Discord.Rest public override string Respond(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent component = null, Embed embed = null) => throw new NotSupportedException("Autocomplete interactions cannot be deferred!"); - IDiscordInteractionData IDiscordInteraction.Data => Data; - + //IAutocompleteInteraction + /// + IAutocompleteInteractionData IAutocompleteInteraction.Data => Data; } } diff --git a/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestAutocompleteInteractionData.cs b/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestAutocompleteInteractionData.cs index 10c4f403e..135eb88ea 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestAutocompleteInteractionData.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestAutocompleteInteractionData.cs @@ -11,7 +11,7 @@ namespace Discord.Rest /// /// Represents the data for a . /// - public class RestAutocompleteInteractionData : IDiscordInteractionData + public class RestAutocompleteInteractionData : IAutocompleteInteractionData { /// /// Gets the name of the invoked command. diff --git a/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestSlashCommand.cs b/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestSlashCommand.cs index a5971c8e6..4e4989d29 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestSlashCommand.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/SlashCommands/RestSlashCommand.cs @@ -11,7 +11,7 @@ namespace Discord.Rest /// /// Represents a REST-based slash command. /// - public class RestSlashCommand : RestCommandBase, IDiscordInteraction + public class RestSlashCommand : RestCommandBase, ISlashCommandInteraction, IDiscordInteraction { /// /// Gets the data associated with this interaction. @@ -39,6 +39,8 @@ namespace Discord.Rest Data = await RestSlashCommandData.CreateAsync(client, dataModel, Guild, Channel); } - IDiscordInteractionData IDiscordInteraction.Data => Data; + //ISlashCommandInteraction + /// + IApplicationCommandInteractionData ISlashCommandInteraction.Data => Data; } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/MessageCommands/SocketMessageCommand.cs b/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/MessageCommands/SocketMessageCommand.cs index 99c45b6c3..0aa061439 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/MessageCommands/SocketMessageCommand.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/MessageCommands/SocketMessageCommand.cs @@ -6,7 +6,7 @@ namespace Discord.WebSocket /// /// Represents a Websocket-based slash command received over the gateway. /// - public class SocketMessageCommand : SocketCommandBase, IDiscordInteraction + public class SocketMessageCommand : SocketCommandBase, IMessageCommandInteraction, IDiscordInteraction { /// /// The data associated with this interaction. @@ -34,6 +34,12 @@ namespace Discord.WebSocket return entity; } + //IMessageCommandInteraction + /// + IMessageCommandInteractionData IMessageCommandInteraction.Data => Data; + + //IDiscordInteraction + /// IDiscordInteractionData IDiscordInteraction.Data => Data; } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/MessageCommands/SocketMessageCommandData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/MessageCommands/SocketMessageCommandData.cs index dc2ab3a19..71a30b44a 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/MessageCommands/SocketMessageCommandData.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/MessageCommands/SocketMessageCommandData.cs @@ -7,7 +7,7 @@ namespace Discord.WebSocket /// /// Represents the data tied with the interaction. /// - public class SocketMessageCommandData : SocketCommandBaseData, IDiscordInteractionData + public class SocketMessageCommandData : SocketCommandBaseData, IMessageCommandInteractionData, IDiscordInteractionData { /// /// Gets the message associated with this message command. @@ -31,5 +31,9 @@ namespace Discord.WebSocket entity.Update(model); return entity; } + + //IMessageCommandInteractionData + /// + IMessage IMessageCommandInteractionData.Message => Message; } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/UserCommands/SocketUserCommand.cs b/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/UserCommands/SocketUserCommand.cs index b77331790..40ee5b537 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/UserCommands/SocketUserCommand.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/UserCommands/SocketUserCommand.cs @@ -6,7 +6,7 @@ namespace Discord.WebSocket /// /// Represents a Websocket-based slash command received over the gateway. /// - public class SocketUserCommand : SocketCommandBase, IDiscordInteraction + public class SocketUserCommand : SocketCommandBase, IUserCommandInteraction, IDiscordInteraction { /// /// The data associated with this interaction. @@ -34,6 +34,12 @@ namespace Discord.WebSocket return entity; } + //IUserCommandInteraction + /// + IUserCommandInteractionData IUserCommandInteraction.Data => Data; + + //IDiscordInteraction + /// IDiscordInteractionData IDiscordInteraction.Data => Data; } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/UserCommands/SocketUserCommandData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/UserCommands/SocketUserCommandData.cs index 1c6637b7e..eaebbcb06 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/UserCommands/SocketUserCommandData.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/ContextMenuCommands/UserCommands/SocketUserCommandData.cs @@ -7,7 +7,7 @@ namespace Discord.WebSocket /// /// Represents the data tied with the interaction. /// - public class SocketUserCommandData : SocketCommandBaseData, IDiscordInteractionData + public class SocketUserCommandData : SocketCommandBaseData, IUserCommandInteractionData, IDiscordInteractionData { /// /// Gets the user who this command targets. @@ -31,5 +31,9 @@ namespace Discord.WebSocket entity.Update(model); return entity; } + + //IUserCommandInteractionData + /// + IUser IUserCommandInteractionData.User => Member; } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs b/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs index 1b8e69ed6..4cb096e3e 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs @@ -13,7 +13,7 @@ namespace Discord.WebSocket /// /// Represents a Websocket-based interaction type for Message Components. /// - public class SocketMessageComponent : SocketInteraction, IDiscordInteraction + public class SocketMessageComponent : SocketInteraction, IComponentInteraction, IDiscordInteraction { /// /// Gets the data received with this interaction, contains the button that was clicked. @@ -422,6 +422,15 @@ namespace Discord.WebSocket } } + //IComponentInteraction + /// + IComponentInteractionData IComponentInteraction.Data => Data; + + /// + IUserMessage IComponentInteraction.Message => Message; + + //IDiscordInteraction + /// IDiscordInteractionData IDiscordInteraction.Data => Data; } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponentData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponentData.cs index 79f1cee57..71e1d0395 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponentData.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponentData.cs @@ -6,7 +6,7 @@ namespace Discord.WebSocket /// /// Represents the data sent with a . /// - public class SocketMessageComponentData : IDiscordInteractionData + public class SocketMessageComponentData : IComponentInteractionData { /// /// Gets the components Custom Id that was clicked. diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketAutocompleteInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketAutocompleteInteraction.cs index 6d24329b5..13ef87aa6 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketAutocompleteInteraction.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketAutocompleteInteraction.cs @@ -11,7 +11,7 @@ namespace Discord.WebSocket /// /// Represents a received over the gateway. /// - public class SocketAutocompleteInteraction : SocketInteraction, IDiscordInteraction + public class SocketAutocompleteInteraction : SocketInteraction, IAutocompleteInteraction, IDiscordInteraction { /// /// The autocomplete data of this interaction. @@ -115,6 +115,12 @@ namespace Discord.WebSocket public override Task RespondAsync(string text = null, Embed[] embeds = null, bool isTTS = false, bool ephemeral = false, AllowedMentions allowedMentions = null, RequestOptions options = null, MessageComponent component = null, Embed embed = null) => throw new NotSupportedException("Autocomplete interactions cannot be deferred!"); + //IAutocompleteInteraction + /// + IAutocompleteInteractionData IAutocompleteInteraction.Data => Data; + + //IDiscordInteraction + /// IDiscordInteractionData IDiscordInteraction.Data => Data; } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketAutocompleteInteractionData.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketAutocompleteInteractionData.cs index b0527700f..1d9803c02 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketAutocompleteInteractionData.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketAutocompleteInteractionData.cs @@ -8,7 +8,7 @@ namespace Discord.WebSocket /// /// Represents data for a slash commands autocomplete interaction. /// - public class SocketAutocompleteInteractionData : IDiscordInteractionData + public class SocketAutocompleteInteractionData : IAutocompleteInteractionData, IDiscordInteractionData { /// /// Gets the name of the invoked command. diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketSlashCommand.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketSlashCommand.cs index 6aa65974f..5343bb225 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketSlashCommand.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SlashCommands/SocketSlashCommand.cs @@ -6,7 +6,7 @@ namespace Discord.WebSocket /// /// Represents a Websocket-based slash command received over the gateway. /// - public class SocketSlashCommand : SocketCommandBase, IDiscordInteraction + public class SocketSlashCommand : SocketCommandBase, ISlashCommandInteraction, IDiscordInteraction { /// /// The data associated with this interaction. @@ -34,6 +34,12 @@ namespace Discord.WebSocket return entity; } + //ISlashCommandInteraction + /// + IApplicationCommandInteractionData ISlashCommandInteraction.Data => Data; + + //IDiscordInteraction + /// IDiscordInteractionData IDiscordInteraction.Data => Data; } }