Skip to content

Commit 481ccd2

Browse files
committed
fix: add in withComponents to Webhook
1 parent a3fff7b commit 481ccd2

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

packages/discord.js/src/structures/Webhook.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ class Webhook {
137137
* @property {string} [threadName] Name of the thread to create (only available if the webhook is in a forum channel)
138138
* @property {Snowflake[]} [appliedTags]
139139
* The tags to apply to the created thread (only available if the webhook is in a forum channel)
140+
* @property {boolean} [withComponents] Whether to allow sending non-interactive components in the message.
141+
* <info>For application-owned webhooks, this property is ignored</info>
140142
*/
141143

142144
/**
@@ -219,7 +221,7 @@ class Webhook {
219221
const query = makeURLSearchParams({
220222
wait: true,
221223
thread_id: messagePayload.options.threadId,
222-
with_components: body?.components?.length > 0,
224+
with_components: messagePayload.options.withComponents,
223225
});
224226

225227
const d = await this.client.rest.post(Routes.webhook(this.id, this.token), {
@@ -300,6 +302,8 @@ class Webhook {
300302
* @property {boolean} [cache=true] Whether to cache the message.
301303
* @property {Snowflake} [threadId] The id of the thread this message belongs to.
302304
* <info>For interaction webhooks, this property is ignored</info>
305+
* @property {boolean} [withComponents] Whether to allow sending non-interactive components in the message.
306+
* <info>For application-owned webhooks, this property is ignored</info>
303307
*/
304308

305309
/**
@@ -339,14 +343,17 @@ class Webhook {
339343

340344
const { body, files } = await messagePayload.resolveBody().resolveFiles();
341345

346+
const query = makeURLSearchParams({
347+
thread_id: messagePayload.options.threadId,
348+
with_components: messagePayload.options.withComponents,
349+
});
350+
342351
const d = await this.client.rest.patch(
343352
Routes.webhookMessage(this.id, this.token, typeof message === 'string' ? message : message.id),
344353
{
345354
body,
346355
files,
347-
query: messagePayload.options.threadId
348-
? makeURLSearchParams({ thread_id: messagePayload.options.threadId })
349-
: undefined,
356+
query,
350357
auth: false,
351358
},
352359
);

packages/discord.js/typings/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7559,6 +7559,7 @@ export interface WebhookEditOptions {
75597559

75607560
export interface WebhookMessageEditOptions extends MessageEditOptions {
75617561
threadId?: Snowflake;
7562+
withComponents?: boolean;
75627563
}
75637564

75647565
export interface InteractionEditReplyOptions
@@ -7578,6 +7579,7 @@ export interface WebhookMessageCreateOptions
75787579
threadId?: Snowflake;
75797580
threadName?: string;
75807581
appliedTags?: readonly Snowflake[];
7582+
withComponents?: boolean;
75817583
}
75827584

75837585
export interface WebSocketOptions {

0 commit comments

Comments
 (0)