From 741ed809d64dd6c9a364f5ab6d8f82b5000677b5 Mon Sep 17 00:00:00 2001 From: d4n Date: Sat, 26 Mar 2022 07:44:13 -0500 Subject: [PATCH] Add missing methods to IComponentInteraction (#2201) --- .../IComponentInteraction.cs | 21 ++++++++++++++++++- .../MessageComponents/RestMessageComponent.cs | 8 +++++++ .../SocketMessageComponent.cs | 16 ++------------ 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteraction.cs b/src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteraction.cs index 2a46e8f18..299ee795d 100644 --- a/src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteraction.cs +++ b/src/Discord.Net.Core/Entities/Interactions/MessageComponents/IComponentInteraction.cs @@ -1,3 +1,6 @@ +using System; +using System.Threading.Tasks; + namespace Discord { /// @@ -6,7 +9,7 @@ namespace Discord public interface IComponentInteraction : IDiscordInteraction { /// - /// Gets the data received with this interaction, contains the button that was clicked. + /// Gets the data received with this component interaction. /// new IComponentInteractionData Data { get; } @@ -14,5 +17,21 @@ namespace Discord /// Gets the message that contained the trigger for this interaction. /// IUserMessage Message { get; } + + /// + /// Updates the message which this component resides in with the type + /// + /// A delegate containing the properties to modify the message with. + /// The options to be used when sending the request. + /// A task that represents the asynchronous operation of updating the message. + Task UpdateAsync(Action func, RequestOptions options = null); + + /// + /// Defers an interaction with the response type 5 (). + /// + /// to defer ephemerally, otherwise . + /// The options to be used when sending the request. + /// A task that represents the asynchronous operation of acknowledging the interaction. + Task DeferLoadingAsync(bool ephemeral = false, RequestOptions options = null); } } diff --git a/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs b/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs index 359b92249..002510eac 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/MessageComponents/RestMessageComponent.cs @@ -492,5 +492,13 @@ namespace Discord.Rest /// IUserMessage IComponentInteraction.Message => Message; + + /// + Task IComponentInteraction.UpdateAsync(Action func, RequestOptions options) + => Task.FromResult(Update(func, options)); + + /// + Task IComponentInteraction.DeferLoadingAsync(bool ephemeral, RequestOptions options) + => Task.FromResult(DeferLoading(ephemeral, options)); } } diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs b/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs index b06979381..aeff465bd 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/MessageComponents/SocketMessageComponent.cs @@ -202,12 +202,7 @@ namespace Discord.WebSocket HasResponded = true; } - /// - /// Updates the message which this component resides in with the type - /// - /// A delegate containing the properties to modify the message with. - /// The request options for this request. - /// A task that represents the asynchronous operation of updating the message. + /// public async Task UpdateAsync(Action func, RequestOptions options = null) { var args = new MessageProperties(); @@ -383,14 +378,7 @@ namespace Discord.WebSocket return await InteractionHelper.SendFollowupAsync(Discord, args, Token, Channel, options).ConfigureAwait(false); } - /// - /// Defers an interaction and responds with type 5 () - /// - /// to send this message ephemerally, otherwise . - /// The request options for this request. - /// - /// A task that represents the asynchronous operation of acknowledging the interaction. - /// + /// public async Task DeferLoadingAsync(bool ephemeral = false, RequestOptions options = null) { if (!InteractionHelper.CanSendResponse(this))