feat(bot): allow clearing embeds from proxied messages

This commit is contained in:
Iris System
2022-12-31 19:24:19 +13:00
parent 31ff2b7c87
commit 25c55df3b3
3 changed files with 23 additions and 9 deletions

View File

@@ -18,6 +18,7 @@ using Newtonsoft.Json.Linq;
using Serilog;
using PluralKit.Core;
using Myriad.Utils;
namespace PluralKit.Bot;
@@ -80,7 +81,7 @@ public class WebhookExecutorService
return webhookMessage;
}
public async Task<Message> EditWebhookMessage(ulong channelId, ulong messageId, string newContent)
public async Task<Message> EditWebhookMessage(ulong channelId, ulong messageId, string newContent, bool clearEmbeds = false)
{
var allowedMentions = newContent.ParseMentions() with
{
@@ -97,10 +98,14 @@ public class WebhookExecutorService
}
var webhook = await _webhookCache.GetWebhook(channelId);
var editReq = new WebhookMessageEditRequest
{
Content = newContent,
AllowedMentions = allowedMentions,
Embeds = (clearEmbeds == true ? Optional<Embed[]>.Some(new Embed[] { }) : Optional<Embed[]>.None()),
};
return await _rest.EditWebhookMessage(webhook.Id, webhook.Token, messageId,
new WebhookMessageEditRequest { Content = newContent, AllowedMentions = allowedMentions },
threadId);
return await _rest.EditWebhookMessage(webhook.Id, webhook.Token, messageId, editReq, threadId);
}
private async Task<Message> ExecuteWebhookInner(Webhook webhook, ProxyRequest req, bool hasRetried = false)