Browse Source

Fix modify bug.

pull/1923/head
quin lynch 4 years ago
parent
commit
6ac1680523
4 changed files with 84 additions and 5 deletions
  1. +72
    -0
      src/Discord.Net.Core/Discord.Net.Core.xml
  2. +3
    -0
      src/Discord.Net.Rest/API/Rest/ModifyInteractionResponseParams.cs
  3. +2
    -2
      src/Discord.Net.Rest/DiscordRestApiClient.cs
  4. +7
    -3
      src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs

+ 72
- 0
src/Discord.Net.Core/Discord.Net.Core.xml View File

@@ -7266,6 +7266,78 @@
<member name="F:Discord.TagType.Emoji">
<summary> The object is an emoji. </summary>
</member>
<member name="T:Discord.Entities.Messages.TimestampTag">
<summary>
Represents a class used to make timestamps in messages. see <see href="https://discord.com/developers/docs/reference#message-formatting-timestamp-styles"/>.
</summary>
</member>
<member name="P:Discord.Entities.Messages.TimestampTag.Style">
<summary>
Gets or sets the style of the timestamp tag.
</summary>
</member>
<member name="P:Discord.Entities.Messages.TimestampTag.Time">
<summary>
Gets or sets the time for this timestamp tag.
</summary>
</member>
<member name="M:Discord.Entities.Messages.TimestampTag.ToString">
<summary>
Converts the current timestamp tag to the string representation supported by discord.
<para>
If the <see cref="P:Discord.Entities.Messages.TimestampTag.Time"/> is null then the default 0 will be used.
</para>
</summary>
<returns>A string thats compatable in a discord message, ex: <code>&lt;t:1625944201:f&gt;</code></returns>
</member>
<member name="M:Discord.Entities.Messages.TimestampTag.FromDateTime(System.DateTime,Discord.Entities.Messages.TimestampTagStyles)">
<summary>
Creates a new timestamp tag with the specified datetime object.
</summary>
<param name="time">The time of this timestamp tag.</param>
<param name="style">The style for this timestamp tag.</param>
<returns>The newly create timestamp tag.</returns>
</member>
<member name="T:Discord.Entities.Messages.TimestampTagStyles">
<summary>
Represents a set of styles to use with a <see cref="T:Discord.Entities.Messages.TimestampTag"/>
</summary>
</member>
<member name="F:Discord.Entities.Messages.TimestampTagStyles.ShortTime">
<summary>
A short time string: 16:20
</summary>
</member>
<member name="F:Discord.Entities.Messages.TimestampTagStyles.LongTime">
<summary>
A long time string: 16:20:30
</summary>
</member>
<member name="F:Discord.Entities.Messages.TimestampTagStyles.ShortDate">
<summary>
A short date string: 20/04/2021
</summary>
</member>
<member name="F:Discord.Entities.Messages.TimestampTagStyles.LongDate">
<summary>
A long date string: 20 April 2021
</summary>
</member>
<member name="F:Discord.Entities.Messages.TimestampTagStyles.ShortDateTime">
<summary>
A short datetime string: 20 April 2021 16:20
</summary>
</member>
<member name="F:Discord.Entities.Messages.TimestampTagStyles.LongDateTime">
<summary>
A long datetime string: Tuesday, 20 April 2021 16:20
</summary>
</member>
<member name="F:Discord.Entities.Messages.TimestampTagStyles.Relative">
<summary>
The relative time to the user: 2 months ago
</summary>
</member>
<member name="T:Discord.ApplicationCommandPermission">
<summary>
Application command permissions allow you to enable or disable commands for specific users or roles within a guild.


+ 3
- 0
src/Discord.Net.Rest/API/Rest/ModifyInteractionResponseParams.cs View File

@@ -17,5 +17,8 @@ namespace Discord.API.Rest

[JsonProperty("allowed_mentions")]
public Optional<AllowedMentions> AllowedMentions { get; set; }

[JsonProperty("components")]
public Optional<API.ActionRowComponent[]> Components { get; set; }
}
}

+ 2
- 2
src/Discord.Net.Rest/DiscordRestApiClient.cs View File

@@ -935,11 +935,11 @@ namespace Discord.API

return await SendAsync<Message>("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<Message> 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<Message>("PATCH", () => $"webhooks/{this.CurrentUserId}/{interactionToken}/messages/@original", args, new BucketIds(), options: options);
}
public async Task DeleteInteractionResponse(string interactionToken, RequestOptions options = null)
{


+ 7
- 3
src/Discord.Net.Rest/Entities/Interactions/InteractionHelper.cs View File

@@ -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<API.Embed[]>()
Embeds = args.Embed.IsSpecified ? new API.Embed[] { args.Embed.Value.ToModel() } : Optional.Create<API.Embed[]>(),
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value.ToModel() : Optional<API.AllowedMentions>.Unspecified,
Components = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() : Optional<API.ActionRowComponent[]>.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<API.Embed[]>()
Embeds = args.Embed.IsSpecified ? new API.Embed[] { args.Embed.Value.ToModel() } : Optional.Create<API.Embed[]>(),
AllowedMentions = args.AllowedMentions.IsSpecified ? args.AllowedMentions.Value.ToModel() : Optional<API.AllowedMentions>.Unspecified,
Components = args.Components.IsSpecified ? args.Components.Value?.Components.Select(x => new API.ActionRowComponent(x)).ToArray() : Optional<API.ActionRowComponent[]>.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)


Loading…
Cancel
Save