From fdf133ef45d3871defb46e47079c2acdd65e69d7 Mon Sep 17 00:00:00 2001 From: Advaith Date: Fri, 29 Oct 2021 01:59:07 -0700 Subject: [PATCH] feat(Attachments): multi uploads and alt text (#223) --- deno/payloads/v8/channel.ts | 4 ++++ deno/payloads/v9/channel.ts | 4 ++++ deno/rest/v8/channel.ts | 36 ++++++++++++------------------------ deno/rest/v8/interactions.ts | 30 ++++++------------------------ deno/rest/v8/webhook.ts | 36 ++++++++++++------------------------ deno/rest/v9/channel.ts | 36 ++++++++++++------------------------ deno/rest/v9/interactions.ts | 30 ++++++------------------------ deno/rest/v9/webhook.ts | 36 ++++++++++++------------------------ payloads/v8/channel.ts | 4 ++++ payloads/v9/channel.ts | 4 ++++ rest/v8/channel.ts | 36 ++++++++++++------------------------ rest/v8/interactions.ts | 30 ++++++------------------------ rest/v8/webhook.ts | 36 ++++++++++++------------------------ rest/v9/channel.ts | 36 ++++++++++++------------------------ rest/v9/interactions.ts | 30 ++++++------------------------ rest/v9/webhook.ts | 36 ++++++++++++------------------------ 16 files changed, 136 insertions(+), 288 deletions(-) diff --git a/deno/payloads/v8/channel.ts b/deno/payloads/v8/channel.ts index d97c1fb1f..21ecbde34 100644 --- a/deno/payloads/v8/channel.ts +++ b/deno/payloads/v8/channel.ts @@ -807,6 +807,10 @@ export interface APIAttachment { * Name of file attached */ filename: string; + /** + * Description for the file + */ + description?: string; /** * The attachment's media type * diff --git a/deno/payloads/v9/channel.ts b/deno/payloads/v9/channel.ts index 2f2cbf08e..96bd316d7 100644 --- a/deno/payloads/v9/channel.ts +++ b/deno/payloads/v9/channel.ts @@ -936,6 +936,10 @@ export interface APIAttachment { * Name of file attached */ filename: string; + /** + * Description for the file + */ + description?: string; /** * The attachment's media type * diff --git a/deno/rest/v8/channel.ts b/deno/rest/v8/channel.ts index b26683e42..b8272ca37 100644 --- a/deno/rest/v8/channel.ts +++ b/deno/rest/v8/channel.ts @@ -214,28 +214,23 @@ export interface RESTPostAPIChannelMessageJSONBody { * See https://discord.com/developers/docs/resources/sticker#sticker-object */ sticker_ids?: [Snowflake] | [Snowflake, Snowflake] | [Snowflake, Snowflake, Snowflake]; + /** + * Attachment objects with filename and description + */ + attachments?: Pick & Partial>[]; } /** * https://discord.com/developers/docs/resources/channel#create-message */ export type RESTPostAPIChannelMessageFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIChannelMessageJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/channel#create-message @@ -332,6 +327,8 @@ export interface RESTPatchAPIChannelMessageJSONBody { /** * Attached files to keep * + * Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body. + * * See https://discord.com/developers/docs/resources/channel#attachment-object */ attachments?: APIAttachment[] | null; @@ -347,22 +344,13 @@ export interface RESTPatchAPIChannelMessageJSONBody { * https://discord.com/developers/docs/resources/channel#edit-message */ export type RESTPatchAPIChannelMessageFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPatchAPIChannelMessageJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPatchAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/channel#edit-message */ diff --git a/deno/rest/v8/interactions.ts b/deno/rest/v8/interactions.ts index 4eb450ff6..bd98a0c63 100644 --- a/deno/rest/v8/interactions.ts +++ b/deno/rest/v8/interactions.ts @@ -126,22 +126,13 @@ export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse; * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */ export type RESTPostAPIInteractionCallbackFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIInteractionCallbackJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIInteractionCallbackJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response @@ -177,22 +168,13 @@ export type RESTPostAPIInteractionFollowupJSONBody = APIInteractionResponseCallb * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIInteractionFollowupJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIInteractionFollowupJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message diff --git a/deno/rest/v8/webhook.ts b/deno/rest/v8/webhook.ts index a80c2ca26..c385635a2 100644 --- a/deno/rest/v8/webhook.ts +++ b/deno/rest/v8/webhook.ts @@ -135,28 +135,23 @@ export interface RESTPostAPIWebhookWithTokenJSONBody { * See https://discord.com/developers/docs/interactions/message-components#component-object */ components?: APIActionRowComponent[]; + /** + * Attachment objects with filename and description + */ + attachments?: Pick & Partial>[]; } /** * https://discord.com/developers/docs/resources/webhook#execute-webhook */ export type RESTPostAPIWebhookWithTokenFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIWebhookWithTokenJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIWebhookWithTokenJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/webhook#execute-webhook-querystring-params @@ -235,6 +230,8 @@ export interface RESTPatchAPIWebhookWithTokenMessageJSONBody /** * Attached files to keep * + * Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body. + * * See https://discord.com/developers/docs/resources/channel#attachment-object */ attachments?: APIAttachment[] | null; @@ -244,22 +241,13 @@ export interface RESTPatchAPIWebhookWithTokenMessageJSONBody * https://discord.com/developers/docs/resources/webhook#edit-webhook-message */ export type RESTPatchAPIWebhookWithTokenMessageFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPatchAPIWebhookWithTokenMessageJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPatchAPIWebhookWithTokenMessageJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/webhook#edit-webhook-message diff --git a/deno/rest/v9/channel.ts b/deno/rest/v9/channel.ts index e3e2b872d..5e5d77eb5 100644 --- a/deno/rest/v9/channel.ts +++ b/deno/rest/v9/channel.ts @@ -248,28 +248,23 @@ export interface RESTPostAPIChannelMessageJSONBody { * See https://discord.com/developers/docs/resources/sticker#sticker-object */ sticker_ids?: [Snowflake] | [Snowflake, Snowflake] | [Snowflake, Snowflake, Snowflake]; + /** + * Attachment objects with filename and description + */ + attachments?: Pick & Partial>[]; } /** * https://discord.com/developers/docs/resources/channel#create-message */ export type RESTPostAPIChannelMessageFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIChannelMessageJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/channel#create-message @@ -366,6 +361,8 @@ export interface RESTPatchAPIChannelMessageJSONBody { /** * Attached files to keep * + * Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body. + * * See https://discord.com/developers/docs/resources/channel#attachment-object */ attachments?: APIAttachment[] | null; @@ -381,22 +378,13 @@ export interface RESTPatchAPIChannelMessageJSONBody { * https://discord.com/developers/docs/resources/channel#edit-message */ export type RESTPatchAPIChannelMessageFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPatchAPIChannelMessageJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPatchAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/channel#edit-message diff --git a/deno/rest/v9/interactions.ts b/deno/rest/v9/interactions.ts index 7488cf4de..12d3954df 100644 --- a/deno/rest/v9/interactions.ts +++ b/deno/rest/v9/interactions.ts @@ -126,22 +126,13 @@ export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse; * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */ export type RESTPostAPIInteractionCallbackFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIInteractionCallbackJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIInteractionCallbackJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response @@ -177,22 +168,13 @@ export type RESTPostAPIInteractionFollowupJSONBody = APIInteractionResponseCallb * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIInteractionFollowupJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIInteractionFollowupJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message diff --git a/deno/rest/v9/webhook.ts b/deno/rest/v9/webhook.ts index a59bde31b..2f508e96e 100644 --- a/deno/rest/v9/webhook.ts +++ b/deno/rest/v9/webhook.ts @@ -135,28 +135,23 @@ export interface RESTPostAPIWebhookWithTokenJSONBody { * See https://discord.com/developers/docs/interactions/message-components#component-object */ components?: APIActionRowComponent[]; + /** + * Attachment objects with filename and description + */ + attachments?: Pick & Partial>[]; } /** * https://discord.com/developers/docs/resources/webhook#execute-webhook */ export type RESTPostAPIWebhookWithTokenFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIWebhookWithTokenJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIWebhookWithTokenJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/webhook#execute-webhook-querystring-params @@ -239,6 +234,8 @@ export interface RESTPatchAPIWebhookWithTokenMessageJSONBody /** * Attached files to keep * + * Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body. + * * See https://discord.com/developers/docs/resources/channel#attachment-object */ attachments?: APIAttachment[] | null; @@ -248,22 +245,13 @@ export interface RESTPatchAPIWebhookWithTokenMessageJSONBody * https://discord.com/developers/docs/resources/webhook#edit-webhook-message */ export type RESTPatchAPIWebhookWithTokenMessageFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPatchAPIWebhookWithTokenMessageJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPatchAPIWebhookWithTokenMessageJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/webhook#edit-webhook-message diff --git a/payloads/v8/channel.ts b/payloads/v8/channel.ts index 81c9aacd7..6c4edba5b 100644 --- a/payloads/v8/channel.ts +++ b/payloads/v8/channel.ts @@ -807,6 +807,10 @@ export interface APIAttachment { * Name of file attached */ filename: string; + /** + * Description for the file + */ + description?: string; /** * The attachment's media type * diff --git a/payloads/v9/channel.ts b/payloads/v9/channel.ts index 6199571d4..f9b03abbf 100644 --- a/payloads/v9/channel.ts +++ b/payloads/v9/channel.ts @@ -936,6 +936,10 @@ export interface APIAttachment { * Name of file attached */ filename: string; + /** + * Description for the file + */ + description?: string; /** * The attachment's media type * diff --git a/rest/v8/channel.ts b/rest/v8/channel.ts index 5b621a149..69f769a28 100644 --- a/rest/v8/channel.ts +++ b/rest/v8/channel.ts @@ -214,28 +214,23 @@ export interface RESTPostAPIChannelMessageJSONBody { * See https://discord.com/developers/docs/resources/sticker#sticker-object */ sticker_ids?: [Snowflake] | [Snowflake, Snowflake] | [Snowflake, Snowflake, Snowflake]; + /** + * Attachment objects with filename and description + */ + attachments?: Pick & Partial>[]; } /** * https://discord.com/developers/docs/resources/channel#create-message */ export type RESTPostAPIChannelMessageFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIChannelMessageJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/channel#create-message @@ -332,6 +327,8 @@ export interface RESTPatchAPIChannelMessageJSONBody { /** * Attached files to keep * + * Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body. + * * See https://discord.com/developers/docs/resources/channel#attachment-object */ attachments?: APIAttachment[] | null; @@ -347,22 +344,13 @@ export interface RESTPatchAPIChannelMessageJSONBody { * https://discord.com/developers/docs/resources/channel#edit-message */ export type RESTPatchAPIChannelMessageFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPatchAPIChannelMessageJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPatchAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/channel#edit-message */ diff --git a/rest/v8/interactions.ts b/rest/v8/interactions.ts index d4b91f304..fae679483 100644 --- a/rest/v8/interactions.ts +++ b/rest/v8/interactions.ts @@ -126,22 +126,13 @@ export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse; * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */ export type RESTPostAPIInteractionCallbackFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIInteractionCallbackJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIInteractionCallbackJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response @@ -177,22 +168,13 @@ export type RESTPostAPIInteractionFollowupJSONBody = APIInteractionResponseCallb * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIInteractionFollowupJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIInteractionFollowupJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message diff --git a/rest/v8/webhook.ts b/rest/v8/webhook.ts index 4edfe4ccb..4748ce566 100644 --- a/rest/v8/webhook.ts +++ b/rest/v8/webhook.ts @@ -135,28 +135,23 @@ export interface RESTPostAPIWebhookWithTokenJSONBody { * See https://discord.com/developers/docs/interactions/message-components#component-object */ components?: APIActionRowComponent[]; + /** + * Attachment objects with filename and description + */ + attachments?: Pick & Partial>[]; } /** * https://discord.com/developers/docs/resources/webhook#execute-webhook */ export type RESTPostAPIWebhookWithTokenFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIWebhookWithTokenJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIWebhookWithTokenJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/webhook#execute-webhook-querystring-params @@ -235,6 +230,8 @@ export interface RESTPatchAPIWebhookWithTokenMessageJSONBody /** * Attached files to keep * + * Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body. + * * See https://discord.com/developers/docs/resources/channel#attachment-object */ attachments?: APIAttachment[] | null; @@ -244,22 +241,13 @@ export interface RESTPatchAPIWebhookWithTokenMessageJSONBody * https://discord.com/developers/docs/resources/webhook#edit-webhook-message */ export type RESTPatchAPIWebhookWithTokenMessageFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPatchAPIWebhookWithTokenMessageJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPatchAPIWebhookWithTokenMessageJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/webhook#edit-webhook-message diff --git a/rest/v9/channel.ts b/rest/v9/channel.ts index 308f8c861..22796a51d 100644 --- a/rest/v9/channel.ts +++ b/rest/v9/channel.ts @@ -248,28 +248,23 @@ export interface RESTPostAPIChannelMessageJSONBody { * See https://discord.com/developers/docs/resources/sticker#sticker-object */ sticker_ids?: [Snowflake] | [Snowflake, Snowflake] | [Snowflake, Snowflake, Snowflake]; + /** + * Attachment objects with filename and description + */ + attachments?: Pick & Partial>[]; } /** * https://discord.com/developers/docs/resources/channel#create-message */ export type RESTPostAPIChannelMessageFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIChannelMessageJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/channel#create-message @@ -366,6 +361,8 @@ export interface RESTPatchAPIChannelMessageJSONBody { /** * Attached files to keep * + * Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body. + * * See https://discord.com/developers/docs/resources/channel#attachment-object */ attachments?: APIAttachment[] | null; @@ -381,22 +378,13 @@ export interface RESTPatchAPIChannelMessageJSONBody { * https://discord.com/developers/docs/resources/channel#edit-message */ export type RESTPatchAPIChannelMessageFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPatchAPIChannelMessageJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPatchAPIChannelMessageJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/channel#edit-message diff --git a/rest/v9/interactions.ts b/rest/v9/interactions.ts index e68102a0d..b9491d591 100644 --- a/rest/v9/interactions.ts +++ b/rest/v9/interactions.ts @@ -126,22 +126,13 @@ export type RESTPostAPIInteractionCallbackJSONBody = APIInteractionResponse; * https://discord.com/developers/docs/interactions/receiving-and-responding#create-interaction-response */ export type RESTPostAPIInteractionCallbackFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIInteractionCallbackJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIInteractionCallbackJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/interactions/receiving-and-responding#get-original-interaction-response @@ -177,22 +168,13 @@ export type RESTPostAPIInteractionFollowupJSONBody = APIInteractionResponseCallb * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message */ export type RESTPostAPIInteractionFollowupFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIInteractionFollowupJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIInteractionFollowupJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/interactions/receiving-and-responding#create-followup-message diff --git a/rest/v9/webhook.ts b/rest/v9/webhook.ts index ff81e7efb..6befc6bfb 100644 --- a/rest/v9/webhook.ts +++ b/rest/v9/webhook.ts @@ -135,28 +135,23 @@ export interface RESTPostAPIWebhookWithTokenJSONBody { * See https://discord.com/developers/docs/interactions/message-components#component-object */ components?: APIActionRowComponent[]; + /** + * Attachment objects with filename and description + */ + attachments?: Pick & Partial>[]; } /** * https://discord.com/developers/docs/resources/webhook#execute-webhook */ export type RESTPostAPIWebhookWithTokenFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPostAPIWebhookWithTokenJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPostAPIWebhookWithTokenJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/webhook#execute-webhook-querystring-params @@ -239,6 +234,8 @@ export interface RESTPatchAPIWebhookWithTokenMessageJSONBody /** * Attached files to keep * + * Starting with API v10, the `attachments` array must contain all attachments that should be present after edit, including **retained and new** attachments provided in the request body. + * * See https://discord.com/developers/docs/resources/channel#attachment-object */ attachments?: APIAttachment[] | null; @@ -248,22 +245,13 @@ export interface RESTPatchAPIWebhookWithTokenMessageJSONBody * https://discord.com/developers/docs/resources/webhook#edit-webhook-message */ export type RESTPatchAPIWebhookWithTokenMessageFormDataBody = - | { + | ({ /** * JSON stringified message body */ payload_json?: string; - /** - * The file contents - */ - file: unknown; - } - | (RESTPatchAPIWebhookWithTokenMessageJSONBody & { - /** - * The file contents - */ - file: unknown; - }); + } & Record<`files[${bigint}]`, unknown>) + | (RESTPatchAPIWebhookWithTokenMessageJSONBody & Record<`files[${bigint}]`, unknown>); /** * https://discord.com/developers/docs/resources/webhook#edit-webhook-message