feat(types,rest,bot): Add with_components to webhooks (#4152)

* Add with_components to webhook execute and edit

* Fix query param building

* update comments
This commit is contained in:
Fleny
2025-04-27 09:42:51 +02:00
committed by GitHub
parent a584ffc3a3
commit b3de175f13
5 changed files with 21 additions and 6 deletions

View File

@@ -948,7 +948,7 @@ export type BotHelpers<TProps extends TransformersDesiredProperties, TBehavior e
webhookId: BigString,
token: string,
messageId: BigString,
options: InteractionCallbackData & { threadId?: BigString },
options: InteractionCallbackData & { threadId?: BigString; withComponents?: boolean },
) => Promise<SetupDesiredProps<Message, TProps, TBehavior>>
editWebhookWithToken: (
webhookId: BigString,

View File

@@ -13,6 +13,7 @@ export function createRoutes(): RestRoutes {
if (options) {
if (options.threadId) url += `thread_id=${options.threadId}`
if (options.withComponents) url += `&with_components=${options.withComponents}`
}
return url
@@ -31,7 +32,8 @@ export function createRoutes(): RestRoutes {
if (options) {
if (options?.wait !== undefined) url += `wait=${options.wait.toString()}`
if (options.threadId) url += `thread_id=${options.threadId}`
if (options.threadId) url += `&thread_id=${options.threadId}`
if (options.withComponents) url += `&with_components=${options.withComponents}`
}
return url

View File

@@ -1483,7 +1483,7 @@ export interface RestManager {
webhookId: BigString,
token: string,
messageId: BigString,
options: InteractionCallbackData & { threadId?: BigString },
options: InteractionCallbackData & { threadId?: BigString; withComponents?: boolean },
) => Promise<Camelize<DiscordMessage>>
/**
* Edits a webhook using the webhook token, thereby bypassing the need for authentication + permissions.

View File

@@ -33,9 +33,9 @@ export interface RestRoutes {
/** Route for webhook with a id. */
id: (webhookId: BigString) => string
/** Route for handling a webhook with a token. */
webhook: (webhookId: BigString, token: string, options?: { wait?: boolean; threadId?: BigString }) => string
webhook: (webhookId: BigString, token: string, options?: { wait?: boolean; threadId?: BigString; withComponents?: boolean }) => string
/** Route for handling a message that was sent through a webhook. */
message: (webhookId: BigString, token: string, messageId: BigString, options?: { threadId?: BigString }) => string
message: (webhookId: BigString, token: string, messageId: BigString, options?: { threadId?: BigString; withComponents?: boolean }) => string
}
/** Routes for channel related endpoints. */
channels: {

View File

@@ -1062,6 +1062,13 @@ export interface ExecuteWebhook {
wait?: boolean
/** Send a message to the specified thread within a webhook's channel. The thread will automatically be unarchived. */
threadId?: BigString
/**
* Whether to respect the `components` field of the request.
* When enabled, allows application-owned webhooks to use all components and non-owned webhooks to use non-interactive components.
*
* @default false
*/
withComponents?: boolean
/** Name of the thread to create (target channel has to be type of forum channel) */
threadName?: string
/** Array of tag ids to apply to the thread (requires the webhook channel to be a forum or media channel) */
@@ -1080,7 +1087,13 @@ export interface ExecuteWebhook {
embeds?: Camelize<DiscordEmbed>[]
/** Allowed mentions for the message */
allowedMentions?: AllowedMentions
/** the components to include with the message */
/**
* The components to include with the message
*
* @remarks
* Application-owned webhooks can always send components.
* Non-application-owned webhooks cannot send interactive components, and the `components` field will be gnored unless they set the `with_components` query param.
*/
components?: MessageComponents
/** A poll object */
poll?: CreatePoll