mirror of
https://github.com/PluralKit/PluralKit.git
synced 2026-02-04 13:06:50 +00:00
feat(bot): allow clearing embeds from proxied messages
This commit is contained in:
parent
31ff2b7c87
commit
25c55df3b3
3 changed files with 23 additions and 9 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue