From 0e09f2204fc8bcb8b3e3c91930bc79b702300af9 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Thu, 9 Jul 2026 10:14:02 +0100 Subject: [PATCH] feat: Support `is_spoiler` (#1700) --- deno/payloads/v10/message.ts | 2 +- deno/payloads/v9/message.ts | 2 +- deno/rest/v10/channel.ts | 48 ++++++++++++++++++++++++++++-------- deno/rest/v10/webhook.ts | 6 ++--- deno/rest/v9/channel.ts | 48 ++++++++++++++++++++++++++++-------- deno/rest/v9/webhook.ts | 6 ++--- payloads/v10/message.ts | 2 +- payloads/v9/message.ts | 2 +- rest/v10/channel.ts | 48 ++++++++++++++++++++++++++++-------- rest/v10/webhook.ts | 6 ++--- rest/v9/channel.ts | 48 ++++++++++++++++++++++++++++-------- rest/v9/webhook.ts | 6 ++--- 12 files changed, 168 insertions(+), 56 deletions(-) diff --git a/deno/payloads/v10/message.ts b/deno/payloads/v10/message.ts index ee3cdc46..1f902b9c 100644 --- a/deno/payloads/v10/message.ts +++ b/deno/payloads/v10/message.ts @@ -964,7 +964,7 @@ export interface APIAttachment { */ ephemeral?: boolean; /** - * The duration of the audio file (currently for voice messages) + * The duration of the audio or video file */ duration_secs?: number; /** diff --git a/deno/payloads/v9/message.ts b/deno/payloads/v9/message.ts index 1be1cddb..33ce3b80 100644 --- a/deno/payloads/v9/message.ts +++ b/deno/payloads/v9/message.ts @@ -959,7 +959,7 @@ export interface APIAttachment { */ ephemeral?: boolean; /** - * The duration of the audio file (currently for voice messages) + * The duration of the audio or video file */ duration_secs?: number; /** diff --git a/deno/rest/v10/channel.ts b/deno/rest/v10/channel.ts index 38483c78..caabb97e 100644 --- a/deno/rest/v10/channel.ts +++ b/deno/rest/v10/channel.ts @@ -23,7 +23,6 @@ import type { SortOrderType, ForumLayoutType, ChannelFlags, - APIAttachment, APIMessageTopLevelComponent, APIMessagePin, APIAnnouncementThreadChannel, @@ -264,16 +263,42 @@ export type RESTAPIMessageReference = _AddUndefinedToPossiblyUndefinedProperties export type APIMessageReferenceSend = RESTAPIMessageReference; /** - * @see {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure} + * This structure is used in Message Create and Edit requests to set which attachments are in the message and provide their metadata. + * + * When editing, you must provide the `id` of each file to keep, and you can optionally update the `description` and `is_spoiler` fields of existing attachments. + * + * @see {@link https://docs.discord.com/developers/resources/message#attachment-object-attachment-request-structure} */ -export type RESTAPIAttachment = Partial< - Pick -> & { +export interface RESTAPIAttachment { /** - * Attachment id or a number that matches `n` in `files[n]` + * Attachment id, for new attachments this must match the `n` in `files[n]` */ id: Snowflake | number; -}; + /** + * Name of file attached + */ + filename?: string | undefined; + /** + * The title of the file + */ + title?: string | undefined; + /** + * Description (alt text) for the file (max 1024 characters) + */ + description?: string | undefined; + /** + * The duration of the audio or video file (required for voice messages) + */ + duration_secs?: number | undefined; + /** + * Base64 encoded bytearray representing a sampled waveform (required for voice messages) + */ + waveform?: string | undefined; + /** + * Whether the attachment should be marked as a spoiler and blurred until clicked, this sets the `IS_SPOILER` attachment flag + */ + is_spoiler?: boolean | undefined; +} /** * @see {@link https://discord.com/developers/docs/resources/channel#create-message} @@ -322,7 +347,9 @@ export interface RESTPostAPIChannelMessageJSONBody { */ sticker_ids?: [Snowflake, Snowflake, Snowflake] | [Snowflake, Snowflake] | [Snowflake] | undefined; /** - * Attachment objects with filename and description + * Metadata for the attachments. See Uploading Files + * + * @see {@link https://docs.discord.com/developers/reference#uploading-files} */ attachments?: RESTAPIAttachment[] | undefined; /** @@ -465,11 +492,12 @@ export interface RESTPatchAPIChannelMessageJSONBody { */ allowed_mentions?: APIAllowedMentions | null | undefined; /** - * Attached files to keep + * Attached files to keep and their metadata. See Uploading Files * * 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 {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure} + * @see {@link https://docs.discord.com/developers/reference#uploading-files} + * @see {@link https://docs.discord.com/developers/resources/message#attachment-object-attachment-request-structure} */ attachments?: RESTAPIAttachment[] | undefined; /** diff --git a/deno/rest/v10/webhook.ts b/deno/rest/v10/webhook.ts index 695ad40f..9f829424 100644 --- a/deno/rest/v10/webhook.ts +++ b/deno/rest/v10/webhook.ts @@ -137,7 +137,7 @@ export interface RESTPostAPIWebhookWithTokenJSONBody { */ components?: APIMessageTopLevelComponent[] | undefined; /** - * Attachment objects with filename and description + * Metadata for the attachments */ attachments?: RESTAPIAttachment[] | undefined; /** @@ -268,11 +268,11 @@ export type RESTPatchAPIWebhookWithTokenMessageJSONBody = _AddUndefinedToPossibl > > & { /** - * Attached files to keep + * attached files to keep and their metadata * * 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 {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure} + * @see {@link https://docs.discord.com/developers/resources/message#attachment-object-attachment-request-structure} */ attachments?: RESTAPIAttachment[] | undefined; /** diff --git a/deno/rest/v9/channel.ts b/deno/rest/v9/channel.ts index 2a8c3d73..e1f1295e 100644 --- a/deno/rest/v9/channel.ts +++ b/deno/rest/v9/channel.ts @@ -23,7 +23,6 @@ import type { SortOrderType, ForumLayoutType, ChannelFlags, - APIAttachment, APIMessageTopLevelComponent, APIMessagePin, APIAnnouncementThreadChannel, @@ -264,16 +263,42 @@ export type RESTAPIMessageReference = _AddUndefinedToPossiblyUndefinedProperties export type APIMessageReferenceSend = RESTAPIMessageReference; /** - * @see {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure} + * This structure is used in Message Create and Edit requests to set which attachments are in the message and provide their metadata. + * + * When editing, you must provide the `id` of each file to keep, and you can optionally update the `description` and `is_spoiler` fields of existing attachments. + * + * @see {@link https://docs.discord.com/developers/resources/message#attachment-object-attachment-request-structure} */ -export type RESTAPIAttachment = Partial< - Pick -> & { +export interface RESTAPIAttachment { /** - * Attachment id or a number that matches `n` in `files[n]` + * Attachment id, for new attachments this must match the `n` in `files[n]` */ id: Snowflake | number; -}; + /** + * Name of file attached + */ + filename?: string | undefined; + /** + * The title of the file + */ + title?: string | undefined; + /** + * Description (alt text) for the file (max 1024 characters) + */ + description?: string | undefined; + /** + * The duration of the audio or video file (required for voice messages) + */ + duration_secs?: number | undefined; + /** + * Base64 encoded bytearray representing a sampled waveform (required for voice messages) + */ + waveform?: string | undefined; + /** + * Whether the attachment should be marked as a spoiler and blurred until clicked, this sets the `IS_SPOILER` attachment flag + */ + is_spoiler?: boolean | undefined; +} /** * @see {@link https://discord.com/developers/docs/resources/channel#create-message} @@ -329,7 +354,9 @@ export interface RESTPostAPIChannelMessageJSONBody { */ sticker_ids?: [Snowflake, Snowflake, Snowflake] | [Snowflake, Snowflake] | [Snowflake] | undefined; /** - * Attachment objects with filename and description + * Metadata for the attachments. See Uploading Files + * + * @see {@link https://docs.discord.com/developers/reference#uploading-files} */ attachments?: RESTAPIAttachment[] | undefined; /** @@ -479,11 +506,12 @@ export interface RESTPatchAPIChannelMessageJSONBody { */ allowed_mentions?: APIAllowedMentions | null | undefined; /** - * Attached files to keep + * Attached files to keep and their metadata. See Uploading Files * * 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 {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure} + * @see {@link https://docs.discord.com/developers/reference#uploading-files} + * @see {@link https://docs.discord.com/developers/resources/message#attachment-object-attachment-request-structure} */ attachments?: RESTAPIAttachment[] | undefined; /** diff --git a/deno/rest/v9/webhook.ts b/deno/rest/v9/webhook.ts index 6a860691..8e606e26 100644 --- a/deno/rest/v9/webhook.ts +++ b/deno/rest/v9/webhook.ts @@ -137,7 +137,7 @@ export interface RESTPostAPIWebhookWithTokenJSONBody { */ components?: APIMessageTopLevelComponent[] | undefined; /** - * Attachment objects with filename and description + * Metadata for the attachments */ attachments?: RESTAPIAttachment[] | undefined; /** @@ -268,11 +268,11 @@ export type RESTPatchAPIWebhookWithTokenMessageJSONBody = _AddUndefinedToPossibl > > & { /** - * Attached files to keep + * Attached files to keep and their metadata * * 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 {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure} + * @see {@link https://docs.discord.com/developers/resources/message#attachment-object-attachment-request-structure} */ attachments?: RESTAPIAttachment[] | undefined; /** diff --git a/payloads/v10/message.ts b/payloads/v10/message.ts index 3976eff8..2c889e6f 100644 --- a/payloads/v10/message.ts +++ b/payloads/v10/message.ts @@ -964,7 +964,7 @@ export interface APIAttachment { */ ephemeral?: boolean; /** - * The duration of the audio file (currently for voice messages) + * The duration of the audio or video file */ duration_secs?: number; /** diff --git a/payloads/v9/message.ts b/payloads/v9/message.ts index 0da086d0..c329a1f9 100644 --- a/payloads/v9/message.ts +++ b/payloads/v9/message.ts @@ -959,7 +959,7 @@ export interface APIAttachment { */ ephemeral?: boolean; /** - * The duration of the audio file (currently for voice messages) + * The duration of the audio or video file */ duration_secs?: number; /** diff --git a/rest/v10/channel.ts b/rest/v10/channel.ts index a1a55578..7dedfc96 100644 --- a/rest/v10/channel.ts +++ b/rest/v10/channel.ts @@ -23,7 +23,6 @@ import type { SortOrderType, ForumLayoutType, ChannelFlags, - APIAttachment, APIMessageTopLevelComponent, APIMessagePin, APIAnnouncementThreadChannel, @@ -264,16 +263,42 @@ export type RESTAPIMessageReference = _AddUndefinedToPossiblyUndefinedProperties export type APIMessageReferenceSend = RESTAPIMessageReference; /** - * @see {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure} + * This structure is used in Message Create and Edit requests to set which attachments are in the message and provide their metadata. + * + * When editing, you must provide the `id` of each file to keep, and you can optionally update the `description` and `is_spoiler` fields of existing attachments. + * + * @see {@link https://docs.discord.com/developers/resources/message#attachment-object-attachment-request-structure} */ -export type RESTAPIAttachment = Partial< - Pick -> & { +export interface RESTAPIAttachment { /** - * Attachment id or a number that matches `n` in `files[n]` + * Attachment id, for new attachments this must match the `n` in `files[n]` */ id: Snowflake | number; -}; + /** + * Name of file attached + */ + filename?: string | undefined; + /** + * The title of the file + */ + title?: string | undefined; + /** + * Description (alt text) for the file (max 1024 characters) + */ + description?: string | undefined; + /** + * The duration of the audio or video file (required for voice messages) + */ + duration_secs?: number | undefined; + /** + * Base64 encoded bytearray representing a sampled waveform (required for voice messages) + */ + waveform?: string | undefined; + /** + * Whether the attachment should be marked as a spoiler and blurred until clicked, this sets the `IS_SPOILER` attachment flag + */ + is_spoiler?: boolean | undefined; +} /** * @see {@link https://discord.com/developers/docs/resources/channel#create-message} @@ -322,7 +347,9 @@ export interface RESTPostAPIChannelMessageJSONBody { */ sticker_ids?: [Snowflake, Snowflake, Snowflake] | [Snowflake, Snowflake] | [Snowflake] | undefined; /** - * Attachment objects with filename and description + * Metadata for the attachments. See Uploading Files + * + * @see {@link https://docs.discord.com/developers/reference#uploading-files} */ attachments?: RESTAPIAttachment[] | undefined; /** @@ -465,11 +492,12 @@ export interface RESTPatchAPIChannelMessageJSONBody { */ allowed_mentions?: APIAllowedMentions | null | undefined; /** - * Attached files to keep + * Attached files to keep and their metadata. See Uploading Files * * 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 {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure} + * @see {@link https://docs.discord.com/developers/reference#uploading-files} + * @see {@link https://docs.discord.com/developers/resources/message#attachment-object-attachment-request-structure} */ attachments?: RESTAPIAttachment[] | undefined; /** diff --git a/rest/v10/webhook.ts b/rest/v10/webhook.ts index 256a7e38..70a2eb76 100644 --- a/rest/v10/webhook.ts +++ b/rest/v10/webhook.ts @@ -137,7 +137,7 @@ export interface RESTPostAPIWebhookWithTokenJSONBody { */ components?: APIMessageTopLevelComponent[] | undefined; /** - * Attachment objects with filename and description + * Metadata for the attachments */ attachments?: RESTAPIAttachment[] | undefined; /** @@ -268,11 +268,11 @@ export type RESTPatchAPIWebhookWithTokenMessageJSONBody = _AddUndefinedToPossibl > > & { /** - * Attached files to keep + * attached files to keep and their metadata * * 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 {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure} + * @see {@link https://docs.discord.com/developers/resources/message#attachment-object-attachment-request-structure} */ attachments?: RESTAPIAttachment[] | undefined; /** diff --git a/rest/v9/channel.ts b/rest/v9/channel.ts index 7ff35cb7..03c7decb 100644 --- a/rest/v9/channel.ts +++ b/rest/v9/channel.ts @@ -23,7 +23,6 @@ import type { SortOrderType, ForumLayoutType, ChannelFlags, - APIAttachment, APIMessageTopLevelComponent, APIMessagePin, APIAnnouncementThreadChannel, @@ -264,16 +263,42 @@ export type RESTAPIMessageReference = _AddUndefinedToPossiblyUndefinedProperties export type APIMessageReferenceSend = RESTAPIMessageReference; /** - * @see {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure} + * This structure is used in Message Create and Edit requests to set which attachments are in the message and provide their metadata. + * + * When editing, you must provide the `id` of each file to keep, and you can optionally update the `description` and `is_spoiler` fields of existing attachments. + * + * @see {@link https://docs.discord.com/developers/resources/message#attachment-object-attachment-request-structure} */ -export type RESTAPIAttachment = Partial< - Pick -> & { +export interface RESTAPIAttachment { /** - * Attachment id or a number that matches `n` in `files[n]` + * Attachment id, for new attachments this must match the `n` in `files[n]` */ id: Snowflake | number; -}; + /** + * Name of file attached + */ + filename?: string | undefined; + /** + * The title of the file + */ + title?: string | undefined; + /** + * Description (alt text) for the file (max 1024 characters) + */ + description?: string | undefined; + /** + * The duration of the audio or video file (required for voice messages) + */ + duration_secs?: number | undefined; + /** + * Base64 encoded bytearray representing a sampled waveform (required for voice messages) + */ + waveform?: string | undefined; + /** + * Whether the attachment should be marked as a spoiler and blurred until clicked, this sets the `IS_SPOILER` attachment flag + */ + is_spoiler?: boolean | undefined; +} /** * @see {@link https://discord.com/developers/docs/resources/channel#create-message} @@ -329,7 +354,9 @@ export interface RESTPostAPIChannelMessageJSONBody { */ sticker_ids?: [Snowflake, Snowflake, Snowflake] | [Snowflake, Snowflake] | [Snowflake] | undefined; /** - * Attachment objects with filename and description + * Metadata for the attachments. See Uploading Files + * + * @see {@link https://docs.discord.com/developers/reference#uploading-files} */ attachments?: RESTAPIAttachment[] | undefined; /** @@ -479,11 +506,12 @@ export interface RESTPatchAPIChannelMessageJSONBody { */ allowed_mentions?: APIAllowedMentions | null | undefined; /** - * Attached files to keep + * Attached files to keep and their metadata. See Uploading Files * * 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 {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure} + * @see {@link https://docs.discord.com/developers/reference#uploading-files} + * @see {@link https://docs.discord.com/developers/resources/message#attachment-object-attachment-request-structure} */ attachments?: RESTAPIAttachment[] | undefined; /** diff --git a/rest/v9/webhook.ts b/rest/v9/webhook.ts index ee57b5ac..871142f2 100644 --- a/rest/v9/webhook.ts +++ b/rest/v9/webhook.ts @@ -137,7 +137,7 @@ export interface RESTPostAPIWebhookWithTokenJSONBody { */ components?: APIMessageTopLevelComponent[] | undefined; /** - * Attachment objects with filename and description + * Metadata for the attachments */ attachments?: RESTAPIAttachment[] | undefined; /** @@ -268,11 +268,11 @@ export type RESTPatchAPIWebhookWithTokenMessageJSONBody = _AddUndefinedToPossibl > > & { /** - * Attached files to keep + * Attached files to keep and their metadata * * 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 {@link https://discord.com/developers/docs/resources/message#attachment-object-attachment-structure} + * @see {@link https://docs.discord.com/developers/resources/message#attachment-object-attachment-request-structure} */ attachments?: RESTAPIAttachment[] | undefined; /**