From 6ac16805231fc043c21021fb0d35e1e0fe6f21bd Mon Sep 17 00:00:00 2001 From: quin lynch Date: Sat, 10 Jul 2021 20:55:47 -0300 Subject: [PATCH] Fix modify bug. --- src/Discord.Net.Core/Discord.Net.Core.xml | 72 +++++++++++++++++++ .../Rest/ModifyInteractionResponseParams.cs | 3 + src/Discord.Net.Rest/DiscordRestApiClient.cs | 4 +- .../Interactions/InteractionHelper.cs | 10 ++- 4 files changed, 84 insertions(+), 5 deletions(-) diff --git a/src/Discord.Net.Core/Discord.Net.Core.xml b/src/Discord.Net.Core/Discord.Net.Core.xml index 5436dd450..88ca9dfd4 100644 --- a/src/Discord.Net.Core/Discord.Net.Core.xml +++ b/src/Discord.Net.Core/Discord.Net.Core.xml @@ -7266,6 +7266,78 @@ The object is an emoji. + + + Represents a class used to make timestamps in messages. see . + + + + + Gets or sets the style of the timestamp tag. + + + + + Gets or sets the time for this timestamp tag. + + + + + Converts the current timestamp tag to the string representation supported by discord. + + If the is null then the default 0 will be used. + + + A string thats compatable in a discord message, ex: <t:1625944201:f> + + + + Creates a new timestamp tag with the specified datetime object. + + The time of this timestamp tag. + The style for this timestamp tag. + The newly create timestamp tag. + + + + Represents a set of styles to use with a + + + + + A short time string: 16:20 + + + + + A long time string: 16:20:30 + + + + + A short date string: 20/04/2021 + + + + + A long date string: 20 April 2021 + + + + + A short datetime string: 20 April 2021 16:20 + + + + + A long datetime string: Tuesday, 20 April 2021 16:20 + + + + + The relative time to the user: 2 months ago + + Application command permissions allow you to enable or disable commands for specific users or roles within a guild. diff --git a/src/Discord.Net.Rest/API/Rest/ModifyInteractionResponseParams.cs b/src/Discord.Net.Rest/API/Rest/ModifyInteractionResponseParams.cs index 04817f90c..b8c7a124f 100644 --- a/src/Discord.Net.Rest/API/Rest/ModifyInteractionResponseParams.cs +++ b/src/Discord.Net.Rest/API/Rest/ModifyInteractionResponseParams.cs @@ -17,5 +17,8 @@ namespace Discord.API.Rest [JsonProperty("allowed_mentions")] public Optional AllowedMentions { get; set; } + + [JsonProperty("components")] + public Optional Components { get; set; } } } diff --git a/src/Discord.Net.Rest/DiscordRestApiClient.cs b/src/Discord.Net.Rest/DiscordRestApiClient.cs index 6ab4d7ca2..115e3baa5 100644 --- a/src/Discord.Net.Rest/DiscordRestApiClient.cs +++ b/src/Discord.Net.Rest/DiscordRestApiClient.cs @@ -935,11 +935,11 @@ namespace Discord.API return await SendAsync("GET", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", new BucketIds(), options: options).ConfigureAwait(false); } - public async Task ModifyInteractionResponse(ModifyInteractionResponseParams args, string interactionToken, RequestOptions options = null) + public async Task ModifyInteractionResponse(ModifyInteractionResponseParams args, string interactionToken, RequestOptions options = null) { options = RequestOptions.CreateOrClone(options); - await SendJsonAsync("POST", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", args, new BucketIds(), options: options); + return await SendJsonAsync("PATCH", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", args, new BucketIds(), options: options); } public async Task DeleteInteractionResponse(string interactionToken, RequestOptions options = null) { diff --git a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs index 22f12ff48..ec32623c7 100644 --- a/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs +++ b/src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs @@ -305,7 +305,9 @@ namespace Discord.Rest var apiArgs = new API.Rest.ModifyInteractionResponseParams { Content = args.Content, - Embeds = args.Embed.IsSpecified ? new API.Embed[] { args.Embed.Value.ToModel() } : Optional.Create() + Embeds = args.Embed.IsSpecified ? new API.Embed[] { args.Embed.Value.ToModel() } : Optional.Create(), + AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value.ToModel() : Optional.Unspecified, + Components = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() : Optional.Unspecified, }; return await client.ApiClient.ModifyInteractionFollowupMessage(apiArgs, message.Id, message.Token, options).ConfigureAwait(false); @@ -328,10 +330,12 @@ namespace Discord.Rest var apiArgs = new API.Rest.ModifyInteractionResponseParams { Content = args.Content, - Embeds = args.Embed.IsSpecified ? new API.Embed[] { args.Embed.Value.ToModel() } : Optional.Create() + Embeds = args.Embed.IsSpecified ? new API.Embed[] { args.Embed.Value.ToModel() } : Optional.Create(), + AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value.ToModel() : Optional.Unspecified, + Components = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() : Optional.Unspecified, }; - return await client.ApiClient.ModifyInteractionFollowupMessage(apiArgs, message.Id, message.Token, options).ConfigureAwait(false); + return await client.ApiClient.ModifyInteractionResponse(apiArgs, message.Token, options).ConfigureAwait(false); } public static async Task DeletedInteractionResponse(BaseDiscordClient client, RestInteractionMessage message, RequestOptions options = null)