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
Modifier and TypeClassDescriptionstatic class
Class that represents the author of content, possibly including an icon that Discord proxies.static class
Represents a field in an embed.static class
Class that represents a footer at the bottom of an embedstatic class
Represents the information provided to embed an image.static class
Multipurpose class that represents a provider of content, whether directly through creation or indirectly through hosting.static class
Represents the information Discord provided about a thumbnail image that should be displayed with an embed message.static class
Represents the information provided to embed a video. -
Field Summary
Modifier and TypeFieldDescriptionstatic final int
The maximum length the author name of an embed can havestatic final int
The maximum length the description of an embed can havestatic final int
The maximum amount of total visible characters an embed can have
This limit depends on the currentAccountType
and applies to BOTstatic final int
The maximum amount of total visible characters an embed can have
This limit depends on the currentAccountType
and applies to CLIENTstatic final int
The maximum length the footer of an embed can havestatic final int
The maximum length an embed title can havestatic final int
The maximum length any URL can have inside an embedstatic final int
The maximum length an embed field value can have -
Constructor Summary
ConstructorDescriptionMessageEmbed
(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 TypeMethodDescriptionboolean
The information on the creator of the embedded content.getColor()
The color of the stripe on the side of the embed.int
The raw RGB color value for this embed
Defaults toRole.DEFAULT_COLOR_RAW
if no color is setThe description of the embedded resource.The fields in a message embed.The footer (bottom) of the embedded content.getImage()
The information about the image in the message embedint
The 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 theThumbnail
image to be displayed with the embed.The timestamp of the embed.getTitle()
The title of the embed.getType()
TheEmbedType
of 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.boolean
isEmpty()
Whether this embed is empty.boolean
Whether this MessageEmbed can be used in a message.toData()
Creates a newDataObject
used 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
This limit depends on the currentAccountType
and applies to BOT -
EMBED_MAX_LENGTH_CLIENT
public static final int EMBED_MAX_LENGTH_CLIENTThe maximum amount of total visible characters an embed can have
This limit depends on the currentAccountType
and applies to CLIENT
-
-
Constructor Details
-
Method Details
-
getUrl
The url that was originally placed into chat that spawned this embed.
This will return thetitle url
if thetype
of 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
TheEmbedType
of this embed.- Returns:
- The
EmbedType
of this embed.
-
getThumbnail
The information about theThumbnail
image to be displayed with the embed.
If aThumbnail
was not part of this embed, this returns null.- Returns:
- Possibly-null
Thumbnail
instance 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
Provider
containing 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
AuthorInfo
containing 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
!=VIDEO
this will always return null.- Returns:
- Possibly-null
VideoInfo
containing the information about the video which should be embedded.
-
getImage
The information about the image in the message embed- Returns:
- Possibly-null
ImageInfo
containing 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
Field
objects 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_RAW
if 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_BOT
as 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_BOT
as 6000.- Returns:
- True, if this MessageEmbed can be used to send messages
- See Also:
-
equals
-
toData
Creates a newDataObject
used for sending.- Specified by:
toData
in interfaceSerializableData
- Returns:
- JSONObject for this embed
-