class EmbedBuilder

export declare class EmbedBuilder implements JSONEncodable<APIEmbed>

A builder that creates API-compatible JSON data for embeds.

Constructors

constructor(
data?: APIEmbed
)

Creates a new embed from API data.

readonly
fields : readonly EmbedFieldBuilder[]

Gets the fields of this embed.

addFields() : this

Appends fields to the embed.

Examples:Using an array:
const fields: APIEmbedField[] = ...;
const embed = new EmbedBuilder()
	.addFields(fields);
Using rest parameters (variadic):
const embed = new EmbedBuilder()
	.addFields(
		{ name: 'Field 1', value: 'Value 1' },
		{ name: 'Field 2', value: 'Value 2' },
	);

clearAuthor() : this

Clears the author of this embed.

clearColor() : this

Clears the color of this embed.

clearDescription() : this

Clears the description of this embed.

clearFooter() : this

Clears the footer of this embed.

clearImage() : this

Clears the image of this embed.

clearThumbnail() : this

Clears the thumbnail of this embed.

clearTimestamp() : this

Clears the timestamp of this embed.

clearTitle() : this

Clears the title of this embed.

clearURL() : this

Clears the URL of this embed.

setAuthor() : this

Sets the author of this embed.

setColor(
color: number
) : this

Sets the color of this embed.

setDescription(
description: string
) : this

Sets the description of this embed.

setFields() : this

Sets the fields for this embed.

setFooter() : this

Sets the footer of this embed.

setImage(
url: string
) : this

Sets the image of this embed.

setThumbnail(
url: string
) : this

Sets the thumbnail of this embed.

setTimestamp(
timestamp?: Date | number | string
) : this

Sets the timestamp of this embed.

setTitle(
title: string
) : this

Sets the title for this embed.

setURL(
url: string
) : this

Sets the URL of this embed.

spliceFields(
index: number
deleteCount: number
) : this

Removes, replaces, or inserts fields for this embed.

Examples:Remove the first field:
embed.spliceFields(0, 1);
Remove the first n fields:
const n = 4;
embed.spliceFields(0, n);
Remove the last field:
embed.spliceFields(-1, 1);

toJSON(
validationOverride?: boolean
) : APIEmbed

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

updateAuthor(
updater: (builder: EmbedAuthorBuilder) => void
) : this

Updates the author of this embed (and creates it if it doesn't exist).

updateFooter(
updater: (builder: EmbedFooterBuilder) => void
) : this

Updates the footer of this embed (and creates it if it doesn't exist).