EmbedBuilder

Represents a embed in a message (image/video preview, rich embed, etc.)
export declare class EmbedBuilder 

constructor(data?)

Constructs a new instance of the EmbedBuilder class
NameTypeOptionalDescription
dataAPIEmbedYesNone
Readonly

addFields(fields)

:

this

Appends fields to the embed
Remarks
This method accepts either an array of fields or a variable number of field parameters. The maximum amount of fields that can be added is 25.
Example
Using an array
const fields: APIEmbedField[] = ...;
const embed = new EmbedBuilder()
	.addFields(fields);
Example
Using rest parameters (variadic)
const embed = new EmbedBuilder()
	.addFields(
		{ name: 'Field 1', value: 'Value 1' },
		{ name: 'Field 2', value: 'Value 2' },
	);
NameTypeOptionalDescription
fieldsRestOrArray<APIEmbedField>No
The fields to add

setAuthor(options)

:

this

Sets the author of this embed
NameTypeOptionalDescription
optionsEmbedAuthorOptions | nullNo
The options for the author

setColor(color)

:

this

Sets the color of this embed
NameTypeOptionalDescription
colornumber | RGBTuple | nullNo
The color of the embed

setDescription(description)

:

this

Sets the description of this embed
NameTypeOptionalDescription
descriptionstring | nullNo
The description

setFields(fields)

:

this

Sets the embed's fields
Remarks
This method is an alias for spliceFields. More specifically, it splices the entire array of fields, replacing them with the provided fields.
You can set a maximum of 25 fields.
NameTypeOptionalDescription
fieldsRestOrArray<APIEmbedField>No
The fields to set

setFooter(options)

:

this

Sets the footer of this embed
NameTypeOptionalDescription
optionsEmbedFooterOptions | nullNo
The options for the footer

setImage(url)

:

this

Sets the image of this embed
NameTypeOptionalDescription
urlstring | nullNo
The URL of the image

setThumbnail(url)

:

this

Sets the thumbnail of this embed
NameTypeOptionalDescription
urlstring | nullNo
The URL of the thumbnail

setTimestamp(timestamp?)

:

this

Sets the timestamp of this embed
NameTypeOptionalDescription
timestampnumber | Date | nullYes
The timestamp or date

setTitle(title)

:

this

Sets the title of this embed
NameTypeOptionalDescription
titlestring | nullNo
The title

setURL(url)

:

this

Sets the URL of this embed
NameTypeOptionalDescription
urlstring | nullNo
The URL

spliceFields(index, deleteCount, fields)

:

this

Removes, replaces, or inserts fields in the embed.
Remarks
This method behaves similarly to Array.prototype.splice. The maximum amount of fields that can be added is 25.
It's useful for modifying and adjusting order of the already-existing fields of an embed.
Example
Remove the first field
embed.spliceFields(0, 1);
Example
Remove the first n fields
const n = 4
embed.spliceFields(0, n);
Example
Remove the last field
embed.spliceFields(-1, 1);
NameTypeOptionalDescription
indexnumberNo
The index to start at
deleteCountnumberNo
The number of fields to remove
fieldsAPIEmbedField[]No
The replacing field objects

toJSON()

:

APIEmbed

Transforms the embed to a plain object