A builder that creates API-compatible JSON data for messages.
Implements
JSONEncodable<RESTPostAPIChannelMessageJSONBody>Creates a new message builder from API data.
Name | Type | Optional | Description |
---|---|---|---|
data | Partial<RESTPostAPIChannelMessageJSONBody> | Yes | The API data to create this message builder with |
Adds action row components to this message.
Name | Type | Optional | Description |
---|---|---|---|
...components | RestOrArray<ActionRowBuilder | APIActionRowComponent<APIComponentInMessageActionRow> | ((builder: ActionRowBuilder) => ActionRowBuilder)> | No | The action row components to add |
Adds attachments to this message.
Name | Type | Optional | Description |
---|---|---|---|
...attachments | RestOrArray<APIAttachment | AttachmentBuilder | ((builder: AttachmentBuilder) => AttachmentBuilder)> | No | The attachments to add |
Adds container components to this message.
Name | Type | Optional | Description |
---|---|---|---|
...components | RestOrArray<APIContainerComponent | ContainerBuilder | ((builder: ContainerBuilder) => ContainerBuilder)> | No | The container components to add |
Appends embeds to this message.
Remarks
The maximum amount of embeds that can be added is 10.Example
Using an array:Example
Using rest parameters (variadic):Name | Type | Optional | Description |
---|---|---|---|
...embeds | RestOrArray<APIEmbed | EmbedBuilder | ((builder: EmbedBuilder) => EmbedBuilder)> | No | The embeds to add |
Adds file components to this message.
Name | Type | Optional | Description |
---|---|---|---|
...components | RestOrArray<APIFileComponent | FileBuilder | ((builder: FileBuilder) => FileBuilder)> | No | The file components to add |
Adds media gallery components to this message.
Name | Type | Optional | Description |
---|---|---|---|
...components | RestOrArray<APIMediaGalleryComponent | MediaGalleryBuilder | ((builder: MediaGalleryBuilder) => MediaGalleryBuilder)> | No | The media gallery components to add |
Adds section components to this message.
Name | Type | Optional | Description |
---|---|---|---|
...components | RestOrArray<APISectionComponent | SectionBuilder | ((builder: SectionBuilder) => SectionBuilder)> | No | The section components to add |
Adds separator components to this message.
Name | Type | Optional | Description |
---|---|---|---|
...components | RestOrArray<APISeparatorComponent | SeparatorBuilder | ((builder: SeparatorBuilder) => SeparatorBuilder)> | No | The separator components to add |
Adds sticker ids to this message.
Name | Type | Optional | Description |
---|---|---|---|
...stickerIds | RestOrArray<Snowflake> | No | The ids of the stickers to add |
Adds text display components to this message.
Name | Type | Optional | Description |
---|---|---|---|
...components | RestOrArray<APITextDisplayComponent | TextDisplayBuilder | ((builder: TextDisplayBuilder) => TextDisplayBuilder)> | No | The text display components to add |
Clears the allowed mentions for this message.
Clears the content of the message.
Clears the flags for this message.
Clears the message reference for this message.
Clears the nonce of the message.
Clears the poll for this message.
Sets the allowed mentions for this message.
Name | Type | Optional | Description |
---|---|---|---|
allowedMentions | AllowedMentionsBuilder | APIAllowedMentions | ((builder: AllowedMentionsBuilder) => AllowedMentionsBuilder) | No | The allowed mentions to set |
Sets attachments for this message.
Name | Type | Optional | Description |
---|---|---|---|
...attachments | RestOrArray<APIAttachment | AttachmentBuilder | ((builder: AttachmentBuilder) => AttachmentBuilder)> | No | The attachments to set |
Sets the content of the message.
Name | Type | Optional | Description |
---|---|---|---|
content | string | No | The content to set |
Sets the embeds for this message.
Name | Type | Optional | Description |
---|---|---|---|
...embeds | RestOrArray<APIEmbed | EmbedBuilder | ((builder: EmbedBuilder) => EmbedBuilder)> | No | The embeds to set |
Sets whether to enforce recent uniqueness of the nonce of this message.
Name | Type | Optional | Description |
---|---|---|---|
enforceNonce | boolean | Yes | Whether to enforce recent uniqueness of the nonce of this message |
Sets the flags for this message.
Name | Type | Optional | Description |
---|---|---|---|
flags | MessageFlags | No | The flags to set |
Sets the message reference for this message.
Name | Type | Optional | Description |
---|---|---|---|
reference | APIMessageReference | MessageReferenceBuilder | ((builder: MessageReferenceBuilder) => MessageReferenceBuilder) | No | The reference to set |
Sets the poll for this message.
Name | Type | Optional | Description |
---|---|---|---|
poll | APIPoll | PollBuilder | ((builder: PollBuilder) => PollBuilder) | No | The poll to set |
Sets the sticker ids of this message.
Name | Type | Optional | Description |
---|---|---|---|
...stickerIds | RestOrArray<Snowflake> | No | The ids of the stickers to set |
Sets whether the message is TTS.
Name | Type | Optional | Description |
---|---|---|---|
tts | boolean | Yes | Whether the message is TTS |
Removes, replaces, or inserts attachments for this message.
Remarks
This method behaves similarly to Array.prototype.splice().It's useful for modifying and adjusting order of the already-existing attachments of a message.Example
Remove the first attachment:Example
Remove the first n attachments:Example
Remove the last attachment:Name | Type | Optional | Description |
---|---|---|---|
start | number | No | The index to start at |
deleteCount | number | No | The amount of attachments to remove |
...attachments | RestOrArray<APIAttachment | AttachmentBuilder | ((builder: AttachmentBuilder) => AttachmentBuilder)> | No | The attachments to insert |
Removes, replaces, or inserts components for this message.
Remarks
This method behaves similarly to Array.prototype.splice().It's useful for modifying and adjusting order of the already-existing components of a message.Example
Remove the first component:Example
Remove the first n components:Example
Remove the last component:Name | Type | Optional | Description |
---|---|---|---|
start | number | No | The index to start at |
deleteCount | number | No | The amount of components to remove |
...components | RestOrArray<APIMessageTopLevelComponent | MessageTopLevelComponentBuilder> | No | The components to insert |
Removes, replaces, or inserts embeds for this message.
Remarks
This method behaves similarly to Array.prototype.splice().It's useful for modifying and adjusting order of the already-existing embeds of a message.Example
Remove the first embed:Example
Remove the first n embeds:Example
Remove the last embed:Name | Type | Optional | Description |
---|---|---|---|
start | number | No | The index to start at |
deleteCount | number | No | The amount of embeds to remove |
...embeds | RestOrArray<APIEmbed | EmbedBuilder | ((builder: EmbedBuilder) => EmbedBuilder)> | No | The embeds to insert |
Removes, replaces, or inserts sticker ids for this message.
Remarks
This method behaves similarly to Array.prototype.splice().It's useful for modifying and adjusting order of the already-existing sticker ids of a message.Example
Remove the first sticker id:Example
Remove the first n sticker ids:Example
Remove the last sticker id:Name | Type | Optional | Description |
---|---|---|---|
index | number | No | The index to start at |
deleteCount | number | No | The amount of sticker ids to remove |
...stickerIds | RestOrArray<Snowflake> | No | The sticker ids to insert |
Serializes this builder to API-compatible JSON data.Note that by disabling validation, there is no guarantee that the resulting object will be valid.
Name | Type | Optional | Description |
---|---|---|---|
validationOverride | boolean | Yes | Force validation to run/not run regardless of your global preference |
Updates the allowed mentions for this message (and creates it if it doesn't exist)
Name | Type | Optional | Description |
---|---|---|---|
updater | (builder: AllowedMentionsBuilder) => void | No | The function to update the allowed mentions with |
Updates the message reference for this message (and creates it if it doesn't exist)
Name | Type | Optional | Description |
---|---|---|---|
updater | (builder: MessageReferenceBuilder) => void | No | The function to update the message reference with |
Updates the poll for this message (and creates it if it doesn't exist)
Name | Type | Optional | Description |
---|---|---|---|
updater | (builder: PollBuilder) => void | No | The function to update the poll with |