Package net.dv8tion.jda.api.entities
Class MessageEmbed
- java.lang.Object
-
- net.dv8tion.jda.api.entities.MessageEmbed
-
- All Implemented Interfaces:
SerializableData
public class MessageEmbed extends java.lang.Object implements 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!- See Also:
EmbedBuilder,Message.getEmbeds()
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMessageEmbed.AuthorInfoClass that represents the author of content, possibly including an icon that Discord proxies.static classMessageEmbed.FieldRepresents a field in an embed.static classMessageEmbed.FooterClass that represents a footer at the bottom of an embedstatic classMessageEmbed.ImageInfoRepresents the information provided to embed an image.static classMessageEmbed.ProviderMultipurpose class that represents a provider of content, whether directly through creation or indirectly through hosting.static classMessageEmbed.ThumbnailRepresents the information Discord provided about a thumbnail image that should be displayed with an embed message.static classMessageEmbed.VideoInfoRepresents the information provided to embed a video.
-
Field Summary
Fields Modifier and Type Field Description static intAUTHOR_MAX_LENGTHThe maximum length the author name of an embed can havestatic intDESCRIPTION_MAX_LENGTHThe maximum length the description of an embed can havestatic intEMBED_MAX_LENGTH_BOTThe maximum amount of total visible characters an embed can have
This limit depends on the currentAccountTypeand applies to BOTstatic intEMBED_MAX_LENGTH_CLIENTThe maximum amount of total visible characters an embed can have
This limit depends on the currentAccountTypeand applies to CLIENTstatic intTEXT_MAX_LENGTHThe maximum length the footer of an embed can havestatic intTITLE_MAX_LENGTHThe maximum length an embed title can havestatic intURL_MAX_LENGTHThe maximum length any URL can have inside an embedstatic intVALUE_MAX_LENGTHThe maximum length an embed field value can have
-
Constructor Summary
Constructors Constructor Description MessageEmbed(java.lang.String url, java.lang.String title, java.lang.String description, EmbedType type, java.time.OffsetDateTime timestamp, int color, MessageEmbed.Thumbnail thumbnail, MessageEmbed.Provider siteProvider, MessageEmbed.AuthorInfo author, MessageEmbed.VideoInfo videoInfo, MessageEmbed.Footer footer, MessageEmbed.ImageInfo image, java.util.List<MessageEmbed.Field> fields)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)MessageEmbed.AuthorInfogetAuthor()The information on the creator of the embedded content.java.awt.ColorgetColor()The color of the stripe on the side of the embed.intgetColorRaw()The raw RGB color value for this embed
Defaults toRole.DEFAULT_COLOR_RAWif no color is setjava.lang.StringgetDescription()The description of the embedded resource.java.util.List<MessageEmbed.Field>getFields()The fields in a message embed.MessageEmbed.FootergetFooter()The footer (bottom) of the embedded content.MessageEmbed.ImageInfogetImage()The information about the image in the message embedintgetLength()The total amount of characters that is displayed when this embed is displayed by the Discord client.MessageEmbed.ProvidergetSiteProvider()The information on site from which the embed was generated from.MessageEmbed.ThumbnailgetThumbnail()The information about theThumbnailimage to be displayed with the embed.java.time.OffsetDateTimegetTimestamp()The timestamp of the embed.java.lang.StringgetTitle()The title of the embed.EmbedTypegetType()TheEmbedTypeof this embed.java.lang.StringgetUrl()The that was originally placed into chat that spawned this embed.MessageEmbed.VideoInfogetVideoInfo()The information about the video which should be displayed as an embed.booleanisEmpty()Whether this embed is empty.booleanisSendable()Whether this MessageEmbed can be used in a message.DataObjecttoData()Creates a newDataObjectused for sending.
-
-
-
Field Detail
-
TITLE_MAX_LENGTH
public static final int TITLE_MAX_LENGTH
The maximum length an embed title can have
-
AUTHOR_MAX_LENGTH
public static final int AUTHOR_MAX_LENGTH
The maximum length the author name of an embed can have
-
VALUE_MAX_LENGTH
public static final int VALUE_MAX_LENGTH
The maximum length an embed field value can have
-
DESCRIPTION_MAX_LENGTH
public static final int DESCRIPTION_MAX_LENGTH
The maximum length the description of an embed can have
-
TEXT_MAX_LENGTH
public static final int TEXT_MAX_LENGTH
The maximum length the footer of an embed can have
-
URL_MAX_LENGTH
public static final int URL_MAX_LENGTH
The maximum length any URL can have inside an embed
-
EMBED_MAX_LENGTH_BOT
public static final int EMBED_MAX_LENGTH_BOT
The maximum amount of total visible characters an embed can have
This limit depends on the currentAccountTypeand applies to BOT
-
EMBED_MAX_LENGTH_CLIENT
public static final int EMBED_MAX_LENGTH_CLIENT
The maximum amount of total visible characters an embed can have
This limit depends on the currentAccountTypeand applies to CLIENT
-
-
Constructor Detail
-
MessageEmbed
public MessageEmbed(java.lang.String url, java.lang.String title, java.lang.String description, EmbedType type, java.time.OffsetDateTime timestamp, int color, MessageEmbed.Thumbnail thumbnail, MessageEmbed.Provider siteProvider, MessageEmbed.AuthorInfo author, MessageEmbed.VideoInfo videoInfo, MessageEmbed.Footer footer, MessageEmbed.ImageInfo image, java.util.List<MessageEmbed.Field> fields)
-
-
Method Detail
-
getUrl
@Nullable public java.lang.String getUrl()
The that was originally placed into chat that spawned this embed.- Returns:
- Possibly-null String containing the original message url.
-
getTitle
@Nullable public java.lang.String 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
@Nullable public java.lang.String 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
@Nonnull public EmbedType getType()
TheEmbedTypeof this embed.- Returns:
- The
EmbedTypeof this embed.
-
getThumbnail
@Nullable public MessageEmbed.Thumbnail 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
@Nullable public MessageEmbed.Provider 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
@Nullable public MessageEmbed.AuthorInfo 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
@Nullable public MessageEmbed.VideoInfo 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.
-
getFooter
@Nullable public MessageEmbed.Footer getFooter()
The footer (bottom) of the embedded content.
This is typically used for timestamps or site icons.- Returns:
- Possibly-null
Footercontaining the embed footer content.
-
getImage
@Nullable public MessageEmbed.ImageInfo getImage()
The information about the image in the message embed- Returns:
- Possibly-null
ImageInfocontaining image information.
-
getFields
@Nonnull public java.util.List<MessageEmbed.Field> 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
@Nullable public java.awt.Color 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
@Nullable public java.time.OffsetDateTime 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:
getLength()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toData
@Nonnull public DataObject toData()
Creates a newDataObjectused for sending.- Specified by:
toDatain interfaceSerializableData- Returns:
- JSONObject for this embed
-
-