Interface Emoji

All Superinterfaces:
Formattable, SerializableData
All Known Subinterfaces:
ApplicationEmoji, CustomEmoji, EmojiUnion, RichCustomEmoji, UnicodeEmoji

public interface Emoji extends SerializableData, Formattable
Represents a Discord Emoji.
This can either be Emoji.Type.UNICODE or Emoji.Type.CUSTOM.

Implements Formattable with getFormatted().

See Also:
  • Method Details

    • fromUnicode

      @Nonnull static UnicodeEmoji fromUnicode(@Nonnull String code)
      Creates a reference for a unicode emoji with the provided unicode.
      This has to be the unicode characters rather than the emoji name.
      A reference of unicode emojis can be found here: Emoji Table.

      Examples

      
       // unicode emoji, escape codes
       fromUnicode("\uD83D\uDE03");
       // codepoint notation
       fromUnicode("U+1F602");
       // unicode emoji
       fromUnicode("😃");
       
      Parameters:
      code - The unicode characters, or codepoint notation such as "U+1F602"
      Returns:
      The new emoji instance
      Throws:
      IllegalArgumentException - If the code is null or empty
    • fromCustom

      @Nonnull static CustomEmoji fromCustom(@Nonnull String name, long id, boolean animated)
      Creates a reference for a custom emoji with the provided name.
      Parameters:
      name - The emoji name
      id - The emoji id
      animated - Whether this emoji is animated
      Returns:
      The new emoji instance
      Throws:
      IllegalArgumentException - If the name is null or empty
    • fromCustom

      @Nonnull static CustomEmoji fromCustom(@Nonnull CustomEmoji emoji)
      Creates a reference for a custom emoji from the provided CustomEmoji
      Parameters:
      emoji - The emoji instance
      Returns:
      The new emoji instance
      Throws:
      IllegalArgumentException - If the emoji is null
    • fromFormatted

      @Nonnull static EmojiUnion fromFormatted(@Nonnull String code)
      Parses the provided markdown formatting, or unicode characters, to an Emoji instance.

      Example

      
       // animated custom emoji
       fromFormatted("<a:dance:123456789123456789>");
       // not animated custom emoji
       fromFormatted("<:dog:123456789123456789>");
       // unicode emoji, escape codes
       fromFormatted("&#92;uD83D&#92;uDE03");
       // codepoint notation
       fromFormatted("U+1F602");
       // unicode emoji
       fromFormatted("😃");
       
      Parameters:
      code - The code to parse
      Returns:
      The emoji instance
      Throws:
      IllegalArgumentException - If the provided code is null or empty
    • fromData

      @Nonnull static EmojiUnion fromData(@Nonnull DataObject emoji)
      Parses the provided JSON representation to an emoji instance.
      Parameters:
      emoji - The emoji json
      Returns:
      The emoji instance
      Throws:
      ParsingException - If the JSON is not a valid emoji
    • getType

      @Nonnull Emoji.Type getType()
      The Emoji.Type of this emoji.
      Returns:
      The Emoji.Type
    • getName

      @Nonnull String getName()
      The name of this emoji.
      This will be the unicode characters if this emoji is not of getType() CUSTOM.
      Returns:
      The unicode or custom name
    • getAsReactionCode

      @Nonnull String getAsReactionCode()
      The reaction code for this emoji.
      For unicode emojis this will be the unicode of said emoji rather than an alias like :smiley:.
      For custom emojis this will be the name and id of said emoji in the format <name>:<id>.
      Returns:
      The unicode if it is an emoji, or the name and id in the format <name>:<id>
    • getFormatted

      @Nonnull String getFormatted()
      Formatted string used in messages.
      For unicode emoji, this is simply getName(). For custom emoji, this will be the mention markdown format <:name:id>.
      Returns:
      The formatted message string
    • formatTo

      default void formatTo(Formatter formatter, int flags, int width, int precision)
      Specified by:
      formatTo in interface Formattable