MessageEmbed
classe · Source
Represents an embed in a message (image/video preview, rich embed, etc.)
Constructor
Parameters
| Name | Type | Description |
|---|---|---|
data? | MessageEmbed | MessageEmbedOptions | APIEmbed | MessageEmbed to clone or raw embed data Default: {}. |
Properties
type
deprecated
The type of this embed, either:
rich- a generic embed rendered from embed attributesimage- an image embedvideo- a video embedgifv- an animated gif image embed rendered as a video embedarticle- an article embedlink- a link embed Source
title
nullable
The title of this embed Source
description
nullable
The description of this embed Source
url
nullable
The URL of this embed Source
color
nullable
The color of this embed Source
timestamp
nullable
The timestamp of this embed Source
fields
The fields of this embed Source
thumbnail
nullable
The thumbnail of this embed (if there is one) Source
image
nullable
The image of this embed, if there is one Source
video
readonly · nullable
The video of this embed (if there is one) Source
author
nullable
The author of this embed (if there is one) Source
provider
nullable
The provider of this embed (if there is one) Source
footer
nullable
The footer of this embed Source
createdAt
readonly · nullable
The date displayed on this embed Source
hexColor
readonly · nullable
The hexadecimal version of the embed color, with a leading hash Source
length
readonly
The accumulated length for the embed title, description, fields, footer text, and author name Source
Methods
equals
Checks if this embed is equal to another one by comparing every single one of their properties. Parameters
| Name | Type | Description |
|---|---|---|
embed | MessageEmbed | APIEmbed | The embed to compare with |
Returns: booleanSource
_fieldEquals
private
Compares two given embed fields to see if they are equal Parameters
| Name | Type | Description |
|---|---|---|
field | EmbedFieldData | The first field to compare |
other | EmbedFieldData | The second field to compare |
Returns: booleanSource
addField
deprecated
Adds a field to the embed (max 25). Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of this field |
value | string | The value of this field |
inline? | boolean | If this field will be displayed inline Default: false. |
Returns: MessageEmbedSource
addFields
Adds fields to the embed (max 25). Parameters
| Name | Type | Description |
|---|---|---|
fields | EmbedFieldData | Array<EmbedFieldData> | The fields to add |
Returns: MessageEmbedSource
spliceFields
Removes, replaces, and inserts fields in the embed (max 25). Parameters
| Name | Type | Description |
|---|---|---|
index | number | The index to start at |
deleteCount | number | The number of fields to remove |
fields? | EmbedFieldData | Array<EmbedFieldData> | The replacing field objects |
Returns: MessageEmbedSource
setFields
Sets the embed's fields (max 25). Parameters
| Name | Type | Description |
|---|---|---|
fields | EmbedFieldData | Array<EmbedFieldData> | The fields to set |
Returns: MessageEmbedSource
setAuthor
Sets the author of this embed. Parameters
| Name | Type | Description |
|---|---|---|
options | string | EmbedAuthorData | null | The options to provide for the author. Provide null to remove the author data. |
deprecatedIconURL? | string | The icon URL of this author. This parameter is deprecated. Use the options parameter instead. |
deprecatedURL? | string | The URL of this author. This parameter is deprecated. Use the options parameter instead. |
Returns: MessageEmbedSource
setColor
Sets the color of this embed. Parameters
| Name | Type | Description |
|---|---|---|
color | ColorResolvable | The color of the embed |
Returns: MessageEmbedSource
setDescription
Sets the description of this embed. Parameters
| Name | Type | Description |
|---|---|---|
description | string | The description |
Returns: MessageEmbedSource
setFooter
Sets the footer of this embed. Parameters
| Name | Type | Description |
|---|---|---|
options | string | EmbedFooterData | null | The options to provide for the footer. Provide null to remove the footer data. |
deprecatedIconURL? | string | The icon URL of this footer. This parameter is deprecated. Use the options parameter instead. |
Returns: MessageEmbedSource
setImage
Sets the image of this embed. Parameters
| Name | Type | Description |
|---|---|---|
url | string | The URL of the image |
Returns: MessageEmbedSource
setThumbnail
Sets the thumbnail of this embed. Parameters
| Name | Type | Description |
|---|---|---|
url | string | The URL of the thumbnail |
Returns: MessageEmbedSource
setTimestamp
Sets the timestamp of this embed. Parameters
| Name | Type | Description |
|---|---|---|
timestamp? | Date | number | null | The timestamp or date. If null then the timestamp will be unset (i.e. when editing an existing MessageEmbed) Default: Date.now(). |
Returns: MessageEmbedSource
setTitle
Sets the title of this embed. Parameters
| Name | Type | Description |
|---|---|---|
title | string | The title |
Returns: MessageEmbedSource
setURL
Sets the URL of this embed. Parameters
| Name | Type | Description |
|---|---|---|
url | string | The URL |
Returns: MessageEmbedSource
toJSON
Transforms the embed to a plain object. Returns: APIEmbed — The raw data of this embed Source
normalizeField
static
Normalizes field input and verifies strings. Parameters
| Name | Type | Description |
|---|---|---|
name | string | The name of the field |
value | string | The value of the field |
inline? | boolean | Set the field to display inline Default: false. |
Returns: EmbedFieldSource
normalizeFields
static
Normalizes field input and resolves strings. Parameters
| Name | Type | Description |
|---|---|---|
fields | EmbedFieldData | Array<EmbedFieldData> | Fields to normalize |
Returns: Array<EmbedField>Source