Skip to main content

Class: MessageBuilder

@sapphire/discord.js-utilities.MessageBuilder

A message builder class, it implements the {@link MessageOptions} interface.

Implements

Constructors

constructor

โ€ข new MessageBuilder(options?)

Parameters

NameType
options?MessageBuilderResolvable

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:45

Properties

allowedMentions

โ€ข Optional allowedMentions: MessageMentionOptions

Which mentions should be parsed from the message content.

Implementation of

MessageOptions.allowedMentions

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:37


content

โ€ข Optional content: null | string

The content for the message. If set to undefined and the builder is used to edit, the content will not be replaced.

Implementation of

MessageOptions.content

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:26


embeds

โ€ข Optional embeds: (MessageEmbed | MessageEmbedOptions | APIEmbed)[]

The embeds for the message. If set to undefined and the builder is used to edit, the embed will not be replaced.

remark There is a maximum of 10 embeds in 1 message

Implementation of

MessageOptions.embeds

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:32


files

โ€ข Optional files: (FileOptions | BufferResolvable | Stream | MessageAttachment)[]

Files to send with the message. This should not be set when editing a message, as Discord does not support editing file attachments.

Implementation of

MessageOptions.files

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:43


nonce

โ€ข Optional nonce: string | number

The nonce for the message.

default ''

Implementation of

MessageOptions.nonce

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:20


tts

โ€ข Optional tts: boolean

Whether or not the message should be spoken aloud.

default false

Implementation of

MessageOptions.tts

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:14


defaults

โ–ช Static defaults: MessageBuilderResolvable = {}

The default values for all MessageBuilder instances.

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:139

Methods

addFile

โ–ธ addFile(file): MessageBuilder

Adds a new value for the MessageBuilder.files field array.

Parameters

NameTypeDescription
fileFileOptions | BufferResolvable | Stream | MessageAttachmentThe file to add to the MessageBuilder.files field array.

Returns

MessageBuilder

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:111


setAllowedMentions

โ–ธ setAllowedMentions(allowedMentions?): MessageBuilder

Sets the value for the MessageBuilder.allowedMentions field.

Parameters

NameTypeDescription
allowedMentions?MessageMentionOptionsWhich mentions should be parsed from the message content.

Returns

MessageBuilder

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:102


setContent

โ–ธ setContent(content?): MessageBuilder

Sets the value for the MessageBuilder.content field.

Parameters

NameTypeDescription
content?stringThe content for the message. If set to undefined and the builder is used to edit, the content will not be replaced.

Returns

MessageBuilder

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:77


setEmbeds

โ–ธ setEmbeds(embeds?): MessageBuilder

Sets the value for the {@link MessageBuilder.embed} field.

remark When providing more than 10 embeds, the array will automatically be sliced down to the first 10.

Parameters

NameTypeDescription
embeds?(MessageEmbed | MessageEmbedOptions | APIEmbed)[]The embeds for the message. If set to undefined and the builder is used to edit, the embed will not be replaced. There is a maximum of 10 embeds per message

Returns

MessageBuilder

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:88


setFile

โ–ธ setFile(file): MessageBuilder

Sets a single value for the MessageBuilder.files field array.

Parameters

NameTypeDescription
fileFileOptions | BufferResolvable | Stream | MessageAttachmentThe file to send with the message. This should not be set when editing a message, as Discord does not support editing file attachments.

Returns

MessageBuilder

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:121


setFiles

โ–ธ setFiles(files?): MessageBuilder

Sets the value for the MessageBuilder.files field.

Parameters

NameTypeDescription
files?(FileOptions | BufferResolvable | Stream | MessageAttachment)[]The files to send with the message. This should not be set when editing a message, as Discord does not support editing file attachments.

Returns

MessageBuilder

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:131


setNonce

โ–ธ setNonce(nonce?): MessageBuilder

Sets the value for the MessageBuilder.nonce field.

Parameters

NameTypeDescription
nonce?stringThe nonce for the message.

Returns

MessageBuilder

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:67


setTTS

โ–ธ setTTS(tts?): MessageBuilder

Sets the value for the MessageBuilder.tts field.

Parameters

NameTypeDescription
tts?booleanWhether or not the message should be spoken aloud.

Returns

MessageBuilder

Defined in

projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:58