From c4f0ee97b78f3d94852d72181dcaf75991c78664 Mon Sep 17 00:00:00 2001 From: Danial Raza Date: Wed, 5 Mar 2025 04:12:24 +0100 Subject: [PATCH 1/2] feat(Webhook): allow setting `withComponents` --- packages/discord.js/src/structures/Webhook.js | 14 +++++++++++--- packages/discord.js/typings/index.d.ts | 2 ++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/discord.js/src/structures/Webhook.js b/packages/discord.js/src/structures/Webhook.js index 15654a8f9142..8b1c6f51d6d2 100644 --- a/packages/discord.js/src/structures/Webhook.js +++ b/packages/discord.js/src/structures/Webhook.js @@ -137,6 +137,8 @@ class Webhook { * @property {string} [threadName] Name of the thread to create (only available if the webhook is in a forum channel) * @property {Snowflake[]} [appliedTags] * The tags to apply to the created thread (only available if the webhook is in a forum channel) + * @property {boolean} [withComponents] Whether to allow sending (non-interactive) components in the message. + * For application-owned webhooks, this property is ignored */ /** @@ -144,6 +146,8 @@ class Webhook { * @typedef {MessageEditOptions} WebhookMessageEditOptions * @property {Snowflake} [threadId] The id of the thread this message belongs to * For interaction webhooks, this property is ignored + * @property {boolean} [withComponents] Whether to allow sending (non-interactive) components in the message. + * For application-owned webhooks, this property is ignored */ /** @@ -217,6 +221,7 @@ class Webhook { const query = makeURLSearchParams({ wait: true, thread_id: messagePayload.options.threadId, + with_components: messagePayload.options.withComponents, }); const { body, files } = await messagePayload.resolveFiles(); @@ -338,14 +343,17 @@ class Webhook { const { body, files } = await messagePayload.resolveBody().resolveFiles(); + const query = makeURLSearchParams({ + thread_id: messagePayload.options.threadId, + with_components: messagePayload.options.withComponents, + }); + const d = await this.client.rest.patch( Routes.webhookMessage(this.id, this.token, typeof message === 'string' ? message : message.id), { body, files, - query: messagePayload.options.threadId - ? makeURLSearchParams({ thread_id: messagePayload.options.threadId }) - : undefined, + query, auth: false, }, ); diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 93a828f29af3..8daccd82a0f0 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -6907,6 +6907,7 @@ export interface WebhookEditOptions { export interface WebhookMessageEditOptions extends MessageEditOptions { threadId?: Snowflake; + withComponents?: boolean; } export interface InteractionEditReplyOptions @@ -6926,6 +6927,7 @@ export interface WebhookMessageCreateOptions threadId?: Snowflake; threadName?: string; appliedTags?: readonly Snowflake[]; + withComponents?: boolean; } export interface WidgetActivity { From bd801280ab7938d9d12deb040fcddc68df6e002e Mon Sep 17 00:00:00 2001 From: Danial Raza Date: Wed, 5 Mar 2025 16:43:04 +0100 Subject: [PATCH 2/2] docs: remove brackets Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> --- packages/discord.js/src/structures/Webhook.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/discord.js/src/structures/Webhook.js b/packages/discord.js/src/structures/Webhook.js index 8b1c6f51d6d2..299f7085060c 100644 --- a/packages/discord.js/src/structures/Webhook.js +++ b/packages/discord.js/src/structures/Webhook.js @@ -137,7 +137,7 @@ class Webhook { * @property {string} [threadName] Name of the thread to create (only available if the webhook is in a forum channel) * @property {Snowflake[]} [appliedTags] * The tags to apply to the created thread (only available if the webhook is in a forum channel) - * @property {boolean} [withComponents] Whether to allow sending (non-interactive) components in the message. + * @property {boolean} [withComponents] Whether to allow sending non-interactive components in the message. * For application-owned webhooks, this property is ignored */ @@ -146,7 +146,7 @@ class Webhook { * @typedef {MessageEditOptions} WebhookMessageEditOptions * @property {Snowflake} [threadId] The id of the thread this message belongs to * For interaction webhooks, this property is ignored - * @property {boolean} [withComponents] Whether to allow sending (non-interactive) components in the message. + * @property {boolean} [withComponents] Whether to allow sending non-interactive components in the message. * For application-owned webhooks, this property is ignored */