feat(webhook): Support with_components (#10945)

feat: support `with_components`
This commit is contained in:
Jiralite
2025-06-22 10:42:01 +01:00
committed by GitHub
parent 127bb59638
commit cbb20566c5

View File

@@ -9,6 +9,7 @@ import {
type RESTPatchAPIWebhookJSONBody, type RESTPatchAPIWebhookJSONBody,
type RESTPatchAPIWebhookResult, type RESTPatchAPIWebhookResult,
type RESTPatchAPIWebhookWithTokenMessageJSONBody, type RESTPatchAPIWebhookWithTokenMessageJSONBody,
type RESTPatchAPIWebhookWithTokenMessageQuery,
type RESTPatchAPIWebhookWithTokenMessageResult, type RESTPatchAPIWebhookWithTokenMessageResult,
type RESTPostAPIWebhookWithTokenGitHubQuery, type RESTPostAPIWebhookWithTokenGitHubQuery,
type RESTPostAPIWebhookWithTokenJSONBody, type RESTPostAPIWebhookWithTokenJSONBody,
@@ -21,10 +22,10 @@ import {
export type CreateWebhookMessageOptions = RESTPostAPIWebhookWithTokenJSONBody & export type CreateWebhookMessageOptions = RESTPostAPIWebhookWithTokenJSONBody &
RESTPostAPIWebhookWithTokenQuery & { files?: RawFile[] }; RESTPostAPIWebhookWithTokenQuery & { files?: RawFile[] };
export type EditWebhookMessageOptions = RESTPatchAPIWebhookWithTokenMessageJSONBody & { export type EditWebhookMessageOptions = RESTPatchAPIWebhookWithTokenMessageJSONBody &
files?: RawFile[]; RESTPatchAPIWebhookWithTokenMessageQuery & {
thread_id?: string; files?: RawFile[];
}; };
export class WebhooksAPI { export class WebhooksAPI {
public constructor(private readonly rest: REST) {} public constructor(private readonly rest: REST) {}
@@ -132,11 +133,11 @@ export class WebhooksAPI {
public async execute( public async execute(
id: Snowflake, id: Snowflake,
token: string, token: string,
{ wait, thread_id, files, ...body }: CreateWebhookMessageOptions, { wait, thread_id, with_components, files, ...body }: CreateWebhookMessageOptions,
{ signal }: Pick<RequestData, 'signal'> = {}, { signal }: Pick<RequestData, 'signal'> = {},
) { ) {
return this.rest.post(Routes.webhook(id, token), { return this.rest.post(Routes.webhook(id, token), {
query: makeURLSearchParams({ wait, thread_id }), query: makeURLSearchParams({ wait, thread_id, with_components }),
files, files,
body, body,
auth: false, auth: false,
@@ -232,11 +233,11 @@ export class WebhooksAPI {
id: Snowflake, id: Snowflake,
token: string, token: string,
messageId: Snowflake, messageId: Snowflake,
{ thread_id, files, ...body }: EditWebhookMessageOptions, { thread_id, with_components, files, ...body }: EditWebhookMessageOptions,
{ signal }: Pick<RequestData, 'signal'> = {}, { signal }: Pick<RequestData, 'signal'> = {},
) { ) {
return this.rest.patch(Routes.webhookMessage(id, token, messageId), { return this.rest.patch(Routes.webhookMessage(id, token, messageId), {
query: makeURLSearchParams({ thread_id }), query: makeURLSearchParams({ thread_id, with_components }),
auth: false, auth: false,
body, body,
signal, signal,