Skip to content

Commit

Permalink
Implement applied tags for webhooks.
Browse files Browse the repository at this point in the history
  • Loading branch information
Nihlus committed Feb 5, 2024
1 parent bc1826c commit ecb59ff
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ Task<Result> DeleteWebhookWithTokenAsync
/// </param>
/// <param name="flags">The message flags.</param>
/// <param name="threadName">The name of the forum thread to create.</param>
/// <param name="appliedTags">The tags to apply to the thread (requires the webhook channel to be a forum or media channel).</param>
/// <param name="ct">The cancellation token for this operation.</param>
/// <returns>
/// A result which may or may not have succeeded. The returned message is null if <paramref name="shouldWait"/>
Expand All @@ -246,6 +247,7 @@ Task<Result> DeleteWebhookWithTokenAsync
Optional<IReadOnlyList<OneOf<FileData, IPartialAttachment>>> attachments = default,
Optional<MessageFlags> flags = default,
Optional<string> threadName = default,
Optional<IReadOnlyList<Snowflake>> appliedTags = default,
CancellationToken ct = default
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public async Task<Result<IMessage?>> ExecuteWebhookAsync
Optional<IReadOnlyList<OneOf<FileData, IPartialAttachment>>> attachments = default,
Optional<MessageFlags> flags = default,
Optional<string> threadName = default,
Optional<IReadOnlyList<Snowflake>> appliedTags = default,
CancellationToken ct = default
)
{
Expand All @@ -139,6 +140,7 @@ public async Task<Result<IMessage?>> ExecuteWebhookAsync
attachments,
flags,
threadName,
appliedTags,
ct
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ public virtual Task<Result<IMessage?>> ExecuteWebhookAsync
Optional<IReadOnlyList<OneOf<FileData, IPartialAttachment>>> attachments = default,
Optional<MessageFlags> flags = default,
Optional<string> threadName = default,
Optional<IReadOnlyList<Snowflake>> appliedTags = default,
CancellationToken ct = default
)
{
Expand Down Expand Up @@ -363,6 +364,7 @@ public virtual Task<Result<IMessage?>> ExecuteWebhookAsync
json.Write("attachments", attachmentList, this.JsonOptions);
json.Write("flags", flags, this.JsonOptions);
json.Write("thread_name", threadName, this.JsonOptions);
json.Write("applied_tags", appliedTags, this.JsonOptions);
}
)
.WithRateLimitContext(this.RateLimitCache);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
using Remora.Discord.Rest.Tests.Extensions;
using Remora.Discord.Rest.Tests.TestBases;
using Remora.Discord.Tests;
using Remora.Rest.Core;
using Remora.Rest.Xunit.Extensions;
using RichardSzalay.MockHttp;
using Xunit;
Expand Down Expand Up @@ -753,6 +754,7 @@ public async Task PerformsNormalRequestCorrectly()
var allowedMentions = new AllowedMentions();
var components = new List<IMessageComponent>();
var flags = MessageFlags.SuppressEmbeds;
var tags = new List<Snowflake>();

var api = CreateAPI
(
Expand All @@ -771,6 +773,7 @@ public async Task PerformsNormalRequestCorrectly()
.WithProperty("allowed_mentions", p => p.IsObject())
.WithProperty("components", p => p.IsArray())
.WithProperty("flags", p => p.Is((int)flags))
.WithProperty("applied_tags", p => p.IsArray())
)
)
.Respond("application/json", SampleRepository.Samples[typeof(IMessage)])
Expand All @@ -787,7 +790,8 @@ public async Task PerformsNormalRequestCorrectly()
tts,
allowedMentions: allowedMentions,
components: components,
flags: flags
flags: flags,
appliedTags: tags
);

ResultAssert.Successful(result);
Expand Down

0 comments on commit ecb59ff

Please sign in to comment.