Skip to content

MessageEmbed

classe · Source

Represents an embed in a message (image/video preview, rich embed, etc.)

Constructor

new MessageEmbed(data?: MessageEmbed | MessageEmbedOptions | APIEmbed)

Parameters

NameTypeDescription
data?MessageEmbed | MessageEmbedOptions | APIEmbedMessageEmbed to clone or raw embed data Default: {}.

Properties

type

deprecated

type: string

The type of this embed, either:

  • rich - a generic embed rendered from embed attributes
  • image - an image embed
  • video - a video embed
  • gifv - an animated gif image embed rendered as a video embed
  • article - an article embed
  • link - a link embed Source

title

nullable

title: string

The title of this embed Source

description

nullable

description: string

The description of this embed Source

url

nullable

url: string

The URL of this embed Source

color

nullable

color: number

The color of this embed Source

timestamp

nullable

timestamp: number

The timestamp of this embed Source

fields

fields: Array<EmbedField>

The fields of this embed Source

thumbnail

nullable

thumbnail: MessageEmbedThumbnail

The thumbnail of this embed (if there is one) Source

image

nullable

image: MessageEmbedImage

The image of this embed, if there is one Source

video

readonly · nullable

video: MessageEmbedVideo

The video of this embed (if there is one) Source

author

nullable

author: MessageEmbedAuthor

The author of this embed (if there is one) Source

provider

nullable

provider: MessageEmbedProvider

The provider of this embed (if there is one) Source

nullable

footer: MessageEmbedFooter

The footer of this embed Source

createdAt

readonly · nullable

createdAt: Date

The date displayed on this embed Source

hexColor

readonly · nullable

hexColor: string

The hexadecimal version of the embed color, with a leading hash Source

length

readonly

length: number

The accumulated length for the embed title, description, fields, footer text, and author name Source

Methods

equals

equals(embed: MessageEmbed | APIEmbed): boolean

Checks if this embed is equal to another one by comparing every single one of their properties. Parameters

NameTypeDescription
embedMessageEmbed | APIEmbedThe embed to compare with

Returns: booleanSource

_fieldEquals

private

_fieldEquals(field: EmbedFieldData, other: EmbedFieldData): boolean

Compares two given embed fields to see if they are equal Parameters

NameTypeDescription
fieldEmbedFieldDataThe first field to compare
otherEmbedFieldDataThe second field to compare

Returns: booleanSource

addField

deprecated

addField(name: string, value: string, inline?: boolean): MessageEmbed

Adds a field to the embed (max 25). Parameters

NameTypeDescription
namestringThe name of this field
valuestringThe value of this field
inline?booleanIf this field will be displayed inline Default: false.

Returns: MessageEmbedSource

addFields

addFields(fields: EmbedFieldData | Array<EmbedFieldData>): MessageEmbed

Adds fields to the embed (max 25). Parameters

NameTypeDescription
fieldsEmbedFieldData | Array<EmbedFieldData>The fields to add

Returns: MessageEmbedSource

spliceFields

spliceFields(index: number, deleteCount: number, fields?: EmbedFieldData | Array<EmbedFieldData>): MessageEmbed

Removes, replaces, and inserts fields in the embed (max 25). Parameters

NameTypeDescription
indexnumberThe index to start at
deleteCountnumberThe number of fields to remove
fields?EmbedFieldData | Array<EmbedFieldData>The replacing field objects

Returns: MessageEmbedSource

setFields

setFields(fields: EmbedFieldData | Array<EmbedFieldData>): MessageEmbed

Sets the embed's fields (max 25). Parameters

NameTypeDescription
fieldsEmbedFieldData | Array<EmbedFieldData>The fields to set

Returns: MessageEmbedSource

setAuthor

setAuthor(options: string | EmbedAuthorData | null, deprecatedIconURL?: string, deprecatedURL?: string): MessageEmbed

Sets the author of this embed. Parameters

NameTypeDescription
optionsstring | EmbedAuthorData | nullThe options to provide for the author.
Provide null to remove the author data.
deprecatedIconURL?stringThe icon URL of this author.
This parameter is deprecated. Use the options parameter instead.
deprecatedURL?stringThe URL of this author.
This parameter is deprecated. Use the options parameter instead.

Returns: MessageEmbedSource

setColor

setColor(color: ColorResolvable): MessageEmbed

Sets the color of this embed. Parameters

NameTypeDescription
colorColorResolvableThe color of the embed

Returns: MessageEmbedSource

setDescription

setDescription(description: string): MessageEmbed

Sets the description of this embed. Parameters

NameTypeDescription
descriptionstringThe description

Returns: MessageEmbedSource

setFooter

setFooter(options: string | EmbedFooterData | null, deprecatedIconURL?: string): MessageEmbed

Sets the footer of this embed. Parameters

NameTypeDescription
optionsstring | EmbedFooterData | nullThe options to provide for the footer.
Provide null to remove the footer data.
deprecatedIconURL?stringThe icon URL of this footer.
This parameter is deprecated. Use the options parameter instead.

Returns: MessageEmbedSource

setImage

setImage(url: string): MessageEmbed

Sets the image of this embed. Parameters

NameTypeDescription
urlstringThe URL of the image

Returns: MessageEmbedSource

setThumbnail

setThumbnail(url: string): MessageEmbed

Sets the thumbnail of this embed. Parameters

NameTypeDescription
urlstringThe URL of the thumbnail

Returns: MessageEmbedSource

setTimestamp

setTimestamp(timestamp?: Date | number | null): MessageEmbed

Sets the timestamp of this embed. Parameters

NameTypeDescription
timestamp?Date | number | nullThe timestamp or date.
If null then the timestamp will be unset (i.e. when editing an existing MessageEmbed) Default: Date.now().

Returns: MessageEmbedSource

setTitle

setTitle(title: string): MessageEmbed

Sets the title of this embed. Parameters

NameTypeDescription
titlestringThe title

Returns: MessageEmbedSource

setURL

setURL(url: string): MessageEmbed

Sets the URL of this embed. Parameters

NameTypeDescription
urlstringThe URL

Returns: MessageEmbedSource

toJSON

toJSON(): APIEmbed

Transforms the embed to a plain object. Returns: APIEmbed — The raw data of this embed Source

normalizeField

static

normalizeField(name: string, value: string, inline?: boolean): EmbedField

Normalizes field input and verifies strings. Parameters

NameTypeDescription
namestringThe name of the field
valuestringThe value of the field
inline?booleanSet the field to display inline Default: false.

Returns: EmbedFieldSource

normalizeFields

static

normalizeFields(fields: EmbedFieldData | Array<EmbedFieldData>): Array<EmbedField>

Normalizes field input and resolves strings. Parameters

NameTypeDescription
fieldsEmbedFieldData | Array<EmbedFieldData>Fields to normalize

Returns: Array<EmbedField>Source

Unofficial software. Not affiliated with or supported by Discord.