Class MessageEmbed


  • public class MessageEmbed
    extends java.lang.Object
    Represents an embed displayed by Discord.
    A visual representation of an Embed can be found at: http://imgur.com/a/yOb5n
    This class has many possibilities for null values, so be careful!
    • Method Detail

      • getUrl

        public java.lang.String getUrl()
        The that was originally placed into chat that spawned this embed.
        Returns:
        Never-null String containing the original message url.
      • getTitle

        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 of EmbedType = IMAGE, this method will return null.
        Returns:
        Possibly-null String containing the title of the embedded resource.
      • getDescription

        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.
      • getThumbnail

        public MessageEmbed.Thumbnail getThumbnail()
        The information about the Thumbnail image to be displayed with the embed.
        If a Thumbnail was not part of this embed, this returns null.
        Returns:
        Possibly-null Thumbnail instance containing general information on the displayable thumbnail.
      • getSiteProvider

        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

        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

        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 this EmbedType != VIDEO this will always return null.
        Returns:
        Possibly-null VideoInfo containing the information about the video which should be embedded.
      • getFooter

        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

        public MessageEmbed.ImageInfo getImage()
        The information about the image in the message embed
        Returns:
        Possibly-null ImageInfo containing image information.
      • getFields

        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) List of Field objects containing field information.
      • getColor

        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 to Role.DEFAULT_COLOR_RAW if no color is set
        Returns:
        The raw RGB color value or default
      • getTimestamp

        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.

        An Embed can only have, at max, 6000 displayable text characters for AccountType.BOT accounts or 2000 displayable text characters for AccountType.CLIENT accounts.

        Both of these values are defined by EMBED_MAX_LENGTH_BOT and EMBED_MAX_LENGTH_CLIENT respectively.

        Returns:
        A never-negative sum of all displayed text characters.
      • isSendable

        public boolean isSendable​(AccountType type)
        Whether this MessageEmbed can be used in a message.
        This applies to Bot- and Client Accounts

        Total Character Limits

        Parameters:
        type - The AccountType to inspect
        Returns:
        True, if this MessageEmbed can be used to send messages for this specified AccountType
        Throws:
        java.lang.IllegalArgumentException - If the provided AccountType is null or not supported by this operation
        See Also:
        getLength()
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toJSONObject

        public org.json.JSONObject toJSONObject()
        Creates a new JSONObject used for sending.
        Returns:
        JSONObject for this embed