Package net.dv8tion.jda.api.entities
Class MessageEmbed
java.lang.Object
net.dv8tion.jda.api.entities.MessageEmbed
- All Implemented Interfaces:
SerializableData
Represents an embed displayed by Discord.
A visual representation of an Embed can be found at: Embed Overview
This class has many possibilities for null values, so be careful!
A visual representation of an Embed can be found at: Embed Overview
This class has many possibilities for null values, so be careful!
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classClass that represents the author of content, possibly including an icon that Discord proxies.static classRepresents a field in an embed.static classClass that represents a footer at the bottom of an embedstatic classRepresents the information provided to embed an image.static classMultipurpose class that represents a provider of content, whether directly through creation or indirectly through hosting.static classRepresents the information Discord provided about a thumbnail image that should be displayed with an embed message.static classRepresents the information provided to embed a video. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe maximum length the author name of an embed can havestatic final intThe maximum length the description of an embed can havestatic final intThe maximum amount of total visible characters an embed can havestatic final intThe maximum amount of total embed fields the embed can holdstatic final intThe maximum length the footer of an embed can havestatic final intThe maximum length an embed title can havestatic final intThe maximum length any URL can have inside an embedstatic final intThe maximum length an embed field value can have -
Constructor Summary
ConstructorsConstructorDescriptionMessageEmbed(String url, String title, String description, EmbedType type, OffsetDateTime timestamp, int color, MessageEmbed.Thumbnail thumbnail, MessageEmbed.Provider siteProvider, MessageEmbed.AuthorInfo author, MessageEmbed.VideoInfo videoInfo, MessageEmbed.Footer footer, MessageEmbed.ImageInfo image, List<MessageEmbed.Field> fields) -
Method Summary
Modifier and TypeMethodDescriptionbooleanThe information on the creator of the embedded content.getColor()The color of the stripe on the side of the embed.intThe raw RGB color value for this embed
Defaults toRole.DEFAULT_COLOR_RAWif no color is setThe description of the embedded resource.@Unmodifiable List<MessageEmbed.Field>The fields in a message embed.The footer (bottom) of the embedded content.getImage()The information about the image in the message embedintThe total amount of characters that is displayed when this embed is displayed by the Discord client.The information on site from which the embed was generated from.The information about theThumbnailimage to be displayed with the embed.The timestamp of the embed.getTitle()The title of the embed.getType()TheEmbedTypeof this embed.getUrl()The url that was originally placed into chat that spawned this embed.The information about the video which should be displayed as an embed.booleanisEmpty()Whether this embed is empty.booleanWhether this MessageEmbed can be used in a message.toData()Creates a newDataObjectused for sending.
-
Field Details
-
TITLE_MAX_LENGTH
public static final int TITLE_MAX_LENGTHThe maximum length an embed title can have -
AUTHOR_MAX_LENGTH
public static final int AUTHOR_MAX_LENGTHThe maximum length the author name of an embed can have -
VALUE_MAX_LENGTH
public static final int VALUE_MAX_LENGTHThe maximum length an embed field value can have -
DESCRIPTION_MAX_LENGTH
public static final int DESCRIPTION_MAX_LENGTHThe maximum length the description of an embed can have -
TEXT_MAX_LENGTH
public static final int TEXT_MAX_LENGTHThe maximum length the footer of an embed can have -
URL_MAX_LENGTH
public static final int URL_MAX_LENGTHThe maximum length any URL can have inside an embed -
EMBED_MAX_LENGTH_BOT
public static final int EMBED_MAX_LENGTH_BOTThe maximum amount of total visible characters an embed can have -
MAX_FIELD_AMOUNT
public static final int MAX_FIELD_AMOUNTThe maximum amount of total embed fields the embed can hold
-
-
Constructor Details
-
Method Details
-
getUrl
The url that was originally placed into chat that spawned this embed.
This will return thetitle urlif thetypeof this embed isRICH.- Returns:
- Possibly-null String containing the link that spawned this embed or the title url
-
getTitle
The title of the embed. Typically this will be the html title of the webpage that is being embedded.
If no title could be found, like the case ofEmbedType=IMAGE, this method will return null.- Returns:
- Possibly-null String containing the title of the embedded resource.
-
getDescription
The description of the embedded resource.
This is provided only if Discord could find a description for the embedded resource using the provided url.
Commonly, this is null. Be careful when using it.- Returns:
- Possibly-null String containing a description of the embedded resource.
-
getType
TheEmbedTypeof this embed.- Returns:
- The
EmbedTypeof this embed.
-
getThumbnail
The information about theThumbnailimage to be displayed with the embed.
If aThumbnailwas not part of this embed, this returns null.- Returns:
- Possibly-null
Thumbnailinstance containing general information on the displayable thumbnail.
-
getSiteProvider
The information on site from which the embed was generated from.
If Discord did not generate any deliverable information about the site, this returns null.- Returns:
- Possibly-null
Providercontaining site information.
-
getAuthor
The information on the creator of the embedded content.
This is typically used to represent the account on the providing site.- Returns:
- Possibly-null
AuthorInfocontaining author information.
-
getVideoInfo
The information about the video which should be displayed as an embed.
This is used when sites with HTML5 players are linked and embedded. Most commonly Youtube.
If thisEmbedType!=VIDEOthis will always return null.- Returns:
- Possibly-null
VideoInfocontaining the information about the video which should be embedded.
-
getImage
The information about the image in the message embed- Returns:
- Possibly-null
ImageInfocontaining image information.
-
getFields
The fields in a message embed.
Message embeds can contain multiple fields, each with a name, value, and a boolean to determine if it will fall in-line with other fields. If the embed contains no fields, an empty list will be returned.- Returns:
- Never-null (but possibly empty) immutable List of
Fieldobjects containing field information.
-
getColor
The color of the stripe on the side of the embed.
If the color is 0 (no color), this will return null.- Returns:
- Possibly-null Color.
-
getColorRaw
public int getColorRaw()The raw RGB color value for this embed
Defaults toRole.DEFAULT_COLOR_RAWif no color is set- Returns:
- The raw RGB color value or default
-
getTimestamp
The timestamp of the embed.- Returns:
- Possibly-null OffsetDateTime object representing the timestamp.
-
isEmpty
public boolean isEmpty()Whether this embed is empty.- Returns:
- True, if this embed has no content
-
getLength
public int getLength()The total amount of characters that is displayed when this embed is displayed by the Discord client.The total character limit is defined by
EMBED_MAX_LENGTH_BOTas 6000.- Returns:
- A never-negative sum of all displayed text characters.
-
isSendable
public boolean isSendable()Whether this MessageEmbed can be used in a message.The total character limit is defined by
EMBED_MAX_LENGTH_BOTas 6000.- Returns:
- True, if this MessageEmbed can be used to send messages
- See Also:
-
equals
-
toData
Creates a newDataObjectused for sending.- Specified by:
toDatain interfaceSerializableData- Returns:
- JSONObject for this embed
-