diff --git a/packages/discord.js/src/structures/Webhook.js b/packages/discord.js/src/structures/Webhook.js
index 0f017054b..84c233c64 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
*/
/**
@@ -219,7 +221,7 @@ class Webhook {
const query = makeURLSearchParams({
wait: true,
thread_id: messagePayload.options.threadId,
- with_components: body?.components?.length > 0,
+ with_components: messagePayload.options.withComponents,
});
const d = await this.client.rest.post(Routes.webhook(this.id, this.token), {
@@ -300,6 +302,8 @@ class Webhook {
* @property {boolean} [cache=true] Whether to cache the message.
* @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
*/
/**
@@ -339,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 17ff0aa40..a990b930d 100644
--- a/packages/discord.js/typings/index.d.ts
+++ b/packages/discord.js/typings/index.d.ts
@@ -7559,6 +7559,7 @@ export interface WebhookEditOptions {
export interface WebhookMessageEditOptions extends MessageEditOptions {
threadId?: Snowflake;
+ withComponents?: boolean;
}
export interface InteractionEditReplyOptions
@@ -7578,6 +7579,7 @@ export interface WebhookMessageCreateOptions
threadId?: Snowflake;
threadName?: string;
appliedTags?: readonly Snowflake[];
+ withComponents?: boolean;
}
export interface WebSocketOptions {