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 class
MessageEmbed.AuthorInfo
Class that represents the author of content, possibly including an icon that Discord proxies.static class
MessageEmbed.Field
Represents a field in an embed.static class
MessageEmbed.Footer
Class that represents a footer at the bottom of an embedstatic class
MessageEmbed.ImageInfo
Represents the information provided to embed an image.static class
MessageEmbed.Provider
Multipurpose class that represents a provider of content, whether directly through creation or indirectly through hosting.static class
MessageEmbed.Thumbnail
Represents the information Discord provided about a thumbnail image that should be displayed with an embed message.static class
MessageEmbed.VideoInfo
Represents the information provided to embed a video.
-
Field Summary
Fields Modifier and Type Field Description static int
AUTHOR_MAX_LENGTH
The maximum length the author name of an embed can havestatic int
DESCRIPTION_MAX_LENGTH
The maximum length the description of an embed can havestatic int
EMBED_MAX_LENGTH_BOT
The maximum amount of total visible characters an embed can have
This limit depends on the currentAccountType
and applies to BOTstatic int
EMBED_MAX_LENGTH_CLIENT
The maximum amount of total visible characters an embed can have
This limit depends on the currentAccountType
and applies to CLIENTstatic int
TEXT_MAX_LENGTH
The maximum length the footer of an embed can havestatic int
TITLE_MAX_LENGTH
The maximum length an embed title can havestatic int
URL_MAX_LENGTH
The maximum length any URL can have inside an embedstatic int
VALUE_MAX_LENGTH
The 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 boolean
equals(java.lang.Object obj)
MessageEmbed.AuthorInfo
getAuthor()
The information on the creator of the embedded content.java.awt.Color
getColor()
The color of the stripe on the side of the embed.int
getColorRaw()
The raw RGB color value for this embed
Defaults toRole.DEFAULT_COLOR_RAW
if no color is setjava.lang.String
getDescription()
The description of the embedded resource.java.util.List<MessageEmbed.Field>
getFields()
The fields in a message embed.MessageEmbed.Footer
getFooter()
The footer (bottom) of the embedded content.MessageEmbed.ImageInfo
getImage()
The information about the image in the message embedint
getLength()
The total amount of characters that is displayed when this embed is displayed by the Discord client.MessageEmbed.Provider
getSiteProvider()
The information on site from which the embed was generated from.MessageEmbed.Thumbnail
getThumbnail()
The information about theThumbnail
image to be displayed with the embed.java.time.OffsetDateTime
getTimestamp()
The timestamp of the embed.java.lang.String
getTitle()
The title of the embed.EmbedType
getType()
TheEmbedType
of this embed.java.lang.String
getUrl()
The that was originally placed into chat that spawned this embed.MessageEmbed.VideoInfo
getVideoInfo()
The information about the video which should be displayed as an embed.boolean
isEmpty()
Whether this embed is empty.boolean
isSendable()
Whether this MessageEmbed can be used in a message.DataObject
toData()
Creates a newDataObject
used 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 currentAccountType
and 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 currentAccountType
and 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()
TheEmbedType
of this embed.- Returns:
- The
EmbedType
of this embed.
-
getThumbnail
@Nullable public MessageEmbed.Thumbnail 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
@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
Provider
containing 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
AuthorInfo
containing 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
!=VIDEO
this will always return null.- Returns:
- Possibly-null
VideoInfo
containing 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
Footer
containing the embed footer content.
-
getImage
@Nullable public MessageEmbed.ImageInfo getImage()
The information about the image in the message embed- Returns:
- Possibly-null
ImageInfo
containing 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
Field
objects 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_RAW
if 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_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:
getLength()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toData
@Nonnull public DataObject toData()
Creates a newDataObject
used for sending.- Specified by:
toData
in interfaceSerializableData
- Returns:
- JSONObject for this embed
-
-