class MessageBuilder

declare class MessageBuilder implements JSONEncodable<RESTPostAPIChannelMessageJSONBody>

Constructors

Creates new attachment builder from API data.

readonly
attachments : readonly AttachmentBuilder[]

Gets the attachments of this message.

readonly
components : readonly ActionRowBuilder[]

Gets the components of this message.

readonly
embeds : readonly EmbedBuilder[]

Gets the embeds of this message.

addAttachments() : this

Adds attachments to this message.

Adds components to this message.

addEmbeds() : this

Appends embeds to this message.

Examples:Using an array:
const embeds: APIEmbed[] = ...;
const message = new MessageBuilder()
	.addEmbeds(embeds);
Using rest parameters (variadic):
const message = new MessageBuilder()
	.addEmbeds(
		{ title: 'Embed 1' },
		{ title: 'Embed 2' },
	);

addStickerIds(
...stickerIds: RestOrArray<Snowflake>
) : this

Adds sticker ids to this message.

clearAllowedMentions() : this

Clears the allowed mentions for this message.

clearContent() : this

Clears the content of the message.

clearFlags() : this

Clears the flags for this message.

clearMessageReference() : this

Clears the message reference for this message.

clearNonce() : this

Clears the nonce of the message.

clearPoll() : this

Clears the poll for this message.

setAllowedMentions() : this

Sets the allowed mentions for this message.

setAttachments() : this

Sets attachments for this message.

Sets the components of this message.

setContent(
content: string
) : this

Sets the content of the message.

setEnforceNonce(
enforceNonce?: boolean
) : this

Sets enforce_nonce for this message.

setFlags() : this

Sets the flags for this message.

setMessageReference() : this

Sets the message reference for this message.

setNonce(
nonce: number | string
) : this

Sets the nonce of the message.

setPoll(
poll: APIPoll | PollBuilder | ((builder: PollBuilder) => PollBuilder)
) : this

Sets the poll for this message.

setStickerIds(
...stickerIds: RestOrArray<Snowflake>
) : this

Sets the sticker ids of this message.

setTTS(
tts?: boolean
) : this

Sets whether the message is TTS.

spliceAttachments(
start: number
deleteCount: number
) : this

Removes, replaces, or inserts attachments for this message.

Examples:Remove the first attachment:
message.spliceAttachments(0, 1);
Remove the first n attachments:
const n = 4;
message.spliceAttachments(0, n);
Remove the last attachment:
message.spliceAttachments(-1, 1);

spliceComponents() : this

Removes, replaces, or inserts components for this message.

Examples:Remove the first component:
message.spliceComponents(0, 1);
Remove the first n components:
const n = 4;
message.spliceComponents(0, n);
Remove the last component:
message.spliceComponents(-1, 1);

spliceEmbeds(
start: number
deleteCount: number
) : this

Removes, replaces, or inserts embeds for this message.

Examples:Remove the first embed:
message.spliceEmbeds(0, 1);
Remove the first n embeds:
const n = 4;
message.spliceEmbeds(0, n);
Remove the last embed:
message.spliceEmbeds(-1, 1);

spliceStickerIds(
index: number
deleteCount: number
...stickerIds: RestOrArray<Snowflake>
) : this

Removes, replaces, or inserts sticker ids for this message.

Examples:Remove the first sticker id:
message.spliceStickerIds(0, 1);
Remove the first n sticker ids:
const n = 4;
message.spliceStickerIds(0, n);
Remove the last sticker id:
message.spliceStickerIds(-1, 1);

toJSON(
validationOverride?: boolean
) : RESTPostAPIChannelMessageJSONBody

Serializes this builder to API-compatible JSON data.Note that by disabling validation, there is no guarantee that the resulting object will be valid.

updateAllowedMentions() : this

Updates the allowed mentions for this message (and creates it if it doesn't exist)

updateMessageReference() : this

Updates the message reference for this message (and creates it if it doesn't exist)

updatePoll(
updater: (builder: PollBuilder) => PollBuilder
) : this

Updates the poll for this message (and creates it if it doesn't exist)