Skip to main content

Class: MessageBuilder

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:12

A message builder class, it implements the MessageCreateOptions interface.

Implements

Constructors

new MessageBuilder()

new MessageBuilder(options?: MessageBuilderResolvable): MessageBuilder

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:53

Parameters

ParameterType
options?MessageBuilderResolvable

Returns

MessageBuilder

Properties

allowedMentions?

optional allowedMentions: MessageMentionOptions

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

Which mentions should be parsed from the message content.

Implementation of

MessageCreateOptions.allowedMentions


components?

optional components: readonly (APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>)[]

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:40

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

Implementation of

MessageCreateOptions.components


content?

optional content: string

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:29

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

Implementation of

MessageCreateOptions.content


embeds?

optional embeds: readonly (APIEmbed | JSONEncodable<APIEmbed>)[]

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:35

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

MessageCreateOptions.embeds


files?

optional files: readonly (Stream | Attachment | BufferResolvable | AttachmentBuilder | AttachmentPayload | JSONEncodable<APIAttachment>)[]

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:51

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

MessageCreateOptions.files


nonce?

optional nonce: string | number

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:23

The nonce for the message.

Default

''

Implementation of

MessageCreateOptions.nonce


tts?

optional tts: boolean

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:17

Whether or not the message should be spoken aloud.

Default

false

Implementation of

MessageCreateOptions.tts


defaults

static defaults: MessageBuilderResolvable = {}

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:158

The default values for all MessageBuilder instances.

Methods

addFile()

addFile(file: Stream | Attachment | BufferResolvable | AttachmentBuilder | AttachmentPayload | JSONEncodable<APIAttachment>): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:130

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

Parameters

ParameterTypeDescription
fileStream | Attachment | BufferResolvable | AttachmentBuilder | AttachmentPayload | JSONEncodable<APIAttachment>The file to add to the MessageBuilder.files field array.

Returns

this


setAllowedMentions()

setAllowedMentions(allowedMentions?: MessageMentionOptions): this

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

Sets the value for the MessageBuilder.allowedMentions field.

Parameters

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

Returns

this


setComponents()

setComponents(components?: readonly (APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>)[]): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:112

Sets the value for the MessageBuilder.components field.

Parameters

ParameterTypeDescription
components?readonly (APIActionRowComponent<APIMessageActionRowComponent> | JSONEncodable<APIActionRowComponent<APIMessageActionRowComponent>> | ActionRowData<MessageActionRowComponentBuilder | MessageActionRowComponentData>)[]The components for the message. If set to undefined and the builder is used to edit, the components will not be replaced.

Returns

this


setContent()

setContent(content?: string): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:86

Sets the value for the MessageBuilder.content field.

Parameters

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

Returns

this


setEmbeds()

setEmbeds(embeds?: readonly (APIEmbed | JSONEncodable<APIEmbed>)[]): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:97

Sets the value for the MessageBuilder.embed field.

Parameters

ParameterTypeDescription
embeds?readonly (APIEmbed | JSONEncodable<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

this

Remark

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


setFile()

setFile(file: Stream | Attachment | BufferResolvable | AttachmentBuilder | AttachmentPayload | JSONEncodable<APIAttachment>): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:140

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

Parameters

ParameterTypeDescription
fileStream | Attachment | BufferResolvable | AttachmentBuilder | AttachmentPayload | JSONEncodable<APIAttachment>The file to send with the message. This should not be set when editing a message, as Discord does not support editing file attachments.

Returns

this


setFiles()

setFiles(files?: (Stream | Attachment | BufferResolvable | AttachmentBuilder | AttachmentPayload | JSONEncodable<APIAttachment>)[]): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:150

Sets the value for the MessageBuilder.files field.

Parameters

ParameterTypeDescription
files?(Stream | Attachment | BufferResolvable | AttachmentBuilder | AttachmentPayload | JSONEncodable<APIAttachment>)[]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

this


setNonce()

setNonce(nonce?: string): this

Defined in: projects/utilities/packages/discord.js-utilities/src/lib/builders/MessageBuilder.ts:76

Sets the value for the MessageBuilder.nonce field.

Parameters

ParameterTypeDescription
nonce?stringThe nonce for the message.

Returns

this


setTTS()

setTTS(tts?: boolean): this

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

Sets the value for the MessageBuilder.tts field.

Parameters

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

Returns

this