From 75892660d0412e2f875342246d6d4e4a69fb1fee Mon Sep 17 00:00:00 2001 From: quin lynch Date: Fri, 6 Aug 2021 13:09:34 -0300 Subject: [PATCH] resolved #88 --- .../API/Common/InteractionCallbackData.cs | 2 +- .../API/Rest/CreateWebhookMessageParams.cs | 2 +- .../Discord.Net.WebSocket.xml | 23 ++++++------------- .../SocketMessageComponent.cs | 18 ++++++--------- .../Slash Commands/SocketSlashCommand.cs | 14 ++++------- .../Entities/Interaction/SocketInteraction.cs | 6 +++-- 6 files changed, 25 insertions(+), 40 deletions(-) diff --git a/src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs b/src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs index f03cb8870..ba233cc6b 100644 --- a/src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs +++ b/src/Discord.Net.Rest/API/Common/InteractionCallbackData.cs @@ -18,7 +18,7 @@ namespace Discord.API // New flags prop. this make the response "ephemeral". see https://discord.com/developers/docs/interactions/slash-commands#interaction-response-interactionapplicationcommandcallbackdata [JsonProperty("flags")] - public Optional Flags { get; set; } + public Optional Flags { get; set; } [JsonProperty("components")] public Optional Components { get; set; } diff --git a/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs b/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs index bd4cc1a6c..1806d487c 100644 --- a/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs +++ b/src/Discord.Net.Rest/API/Rest/CreateWebhookMessageParams.cs @@ -28,7 +28,7 @@ namespace Discord.API.Rest public Optional AllowedMentions { get; set; } [JsonProperty("flags")] - public Optional Flags { get; set; } + public Optional Flags { get; set; } [JsonProperty("components")] public Optional Components { get; set; } diff --git a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml index d22c00429..576fcc5f0 100644 --- a/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml +++ b/src/Discord.Net.WebSocket/Discord.Net.WebSocket.xml @@ -3628,14 +3628,8 @@ - - - Acknowledges this interaction with the . - - The request options for this async request. - - A task that represents the asynchronous operation of acknowledging the interaction. - + + @@ -3747,13 +3741,8 @@ - - - Acknowledges this interaction with the . - - - A task that represents the asynchronous operation of acknowledging the interaction. - + + @@ -3888,10 +3877,12 @@ A task that represents the asynchronous operation of acknowledging the interaction. - + Acknowledges this interaction. + to send this message ephemerally, otherwise . + The request options for this async request. A task that represents the asynchronous operation of acknowledging the interaction. diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs index 921f81de4..a31b30f5f 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Message Components/SocketMessageComponent.cs @@ -123,7 +123,7 @@ namespace Discord.WebSocket }; if (ephemeral) - response.Data.Value.Flags = 64; + response.Data.Value.Flags = MessageFlags.Ephemeral; await InteractionHelper.SendInteractionResponse(this.Discord, response, this.Id, Token, options); } @@ -180,7 +180,7 @@ namespace Discord.WebSocket Components = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() : Optional.Unspecified, - Flags = args.Flags.IsSpecified ? (int?)args.Flags.Value ?? Optional.Unspecified : Optional.Unspecified + Flags = args.Flags.IsSpecified ? args.Flags.Value ?? Optional.Unspecified : Optional.Unspecified } }; @@ -217,23 +217,19 @@ namespace Discord.WebSocket }; if (ephemeral) - args.Flags = 64; + args.Flags = MessageFlags.Ephemeral; return await InteractionHelper.SendFollowupAsync(Discord.Rest, args, Token, Channel, options); } - /// - /// Acknowledges this interaction with the . - /// - /// The request options for this async request. - /// - /// A task that represents the asynchronous operation of acknowledging the interaction. - /// - public override Task DeferAsync(RequestOptions options = null) + /// + public override Task DeferAsync(bool ephemeral = false, RequestOptions options = null) { var response = new API.InteractionResponse() { Type = InteractionResponseType.DeferredUpdateMessage, + Data = ephemeral ? new API.InteractionCallbackData() { Flags = MessageFlags.Ephemeral } : Optional.Unspecified + }; return Discord.Rest.ApiClient.CreateInteractionResponse(response, this.Id, this.Token, options); diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs index 245274613..bff5292c5 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/Slash Commands/SocketSlashCommand.cs @@ -106,7 +106,7 @@ namespace Discord.WebSocket }; if (ephemeral) - response.Data.Value.Flags = 64; + response.Data.Value.Flags = MessageFlags.Ephemeral; await InteractionHelper.SendInteractionResponse(this.Discord, response, this.Id, Token, options); } @@ -141,22 +141,18 @@ namespace Discord.WebSocket }; if (ephemeral) - args.Flags = 64; + args.Flags = MessageFlags.Ephemeral; return await InteractionHelper.SendFollowupAsync(Discord.Rest, args, Token, Channel, options); } - /// - /// Acknowledges this interaction with the . - /// - /// - /// A task that represents the asynchronous operation of acknowledging the interaction. - /// - public override Task DeferAsync(RequestOptions options = null) + /// + public override Task DeferAsync(bool ephemeral = false, RequestOptions options = null) { var response = new API.InteractionResponse { Type = InteractionResponseType.DeferredChannelMessageWithSource, + Data = ephemeral ? new API.InteractionCallbackData() { Flags = MessageFlags.Ephemeral } : Optional.Unspecified }; return Discord.Rest.ApiClient.CreateInteractionResponse(response, this.Id, this.Token, options); diff --git a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs index 4b2e3baec..11145fa2b 100644 --- a/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs +++ b/src/Discord.Net.WebSocket/Entities/Interaction/SocketInteraction.cs @@ -156,15 +156,17 @@ namespace Discord.WebSocket /// A task that represents the asynchronous operation of acknowledging the interaction. /// [Obsolete("This method deprecated, please use DeferAsync instead")] - public Task AcknowledgeAsync(RequestOptions options = null) => DeferAsync(options); + public Task AcknowledgeAsync(RequestOptions options = null) => DeferAsync(options: options); /// /// Acknowledges this interaction. /// + /// to send this message ephemerally, otherwise . + /// The request options for this async request. /// /// A task that represents the asynchronous operation of acknowledging the interaction. /// - public abstract Task DeferAsync(RequestOptions options = null); + public abstract Task DeferAsync(bool ephemeral = false, RequestOptions options = null); private bool CheckToken() {