From 67278fdc1e80ff244b8acba28902b5c3686fc03a Mon Sep 17 00:00:00 2001 From: Skillz4Killz <23035000+Skillz4Killz@users.noreply.github.com> Date: Sun, 14 Nov 2021 14:22:41 +0000 Subject: [PATCH] fix webhook allowed mentions --- src/helpers/webhooks/send_webhook.ts | 11 ++++++++++- src/types/webhooks/execute_webhook.ts | 7 ++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/helpers/webhooks/send_webhook.ts b/src/helpers/webhooks/send_webhook.ts index 7c69ca9b3..2bbfbac78 100644 --- a/src/helpers/webhooks/send_webhook.ts +++ b/src/helpers/webhooks/send_webhook.ts @@ -37,6 +37,15 @@ export async function sendWebhook(bot: Bot, webhookId: bigint, webhookToken: str } } + const allowedMentions = options.allowedMentions + ? { + parse: options.allowedMentions.parse, + repliedUser: options.allowedMentions.repliedUser, + users: options.allowedMentions.users?.map((id) => id.toString()), + roles: options.allowedMentions.roles?.map((id) => id.toString()), + } + : { parse: [] }; + const result = await bot.rest.runMethod( bot.rest, "post", @@ -52,7 +61,7 @@ export async function sendWebhook(bot: Bot, webhookId: bigint, webhookToken: str tts: options.tts, file: options.file, embeds: options.embeds, - allowed_mentions: options.allowedMentions, + allowed_mentions: allowedMentions, } ); if (!options.wait) return; diff --git a/src/types/webhooks/execute_webhook.ts b/src/types/webhooks/execute_webhook.ts index a16604c32..092f2681e 100644 --- a/src/types/webhooks/execute_webhook.ts +++ b/src/types/webhooks/execute_webhook.ts @@ -22,7 +22,12 @@ export interface ExecuteWebhook { /** Embedded `rich` content */ embeds?: Embed[]; /** Allowed mentions for the message */ - allowedMentions?: AllowedMentions; + allowedMentions?: Omit & { + /** Array of role_ids to mention (Max size of 100) */ + roles?: bigint[]; + /** Array of user_ids to mention (Max size of 100) */ + users?: bigint[]; + }; } export type DiscordExecuteWebhook = SnakeCasedPropertiesDeep>;