Interface Emoji
- All Superinterfaces:
Formattable
,SerializableData
- All Known Subinterfaces:
CustomEmoji
,EmojiUnion
,RichCustomEmoji
,UnicodeEmoji
Represents a Discord Emoji.
This can either be
This can either be
Emoji.Type.UNICODE
or Emoji.Type.CUSTOM
.
Implements Formattable
with getFormatted()
.
- See Also:
-
Nested Class Summary
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
static CustomEmoji
fromCustom
(String name, long id, boolean animated) Creates a reference for a custom emoji with the provided name.static CustomEmoji
fromCustom
(CustomEmoji emoji) Creates a reference for a custom emoji from the providedCustomEmoji
static EmojiUnion
fromData
(DataObject emoji) Parses the provided JSON representation to an emoji instance.static EmojiUnion
fromFormatted
(String code) Parses the provided markdown formatting, or unicode characters, to an Emoji instance.static UnicodeEmoji
fromUnicode
(String code) Creates a reference for a unicode emoji with the provided unicode.The reaction code for this emoji.Formatted string used in messages.getName()
The name of this emoji.getType()
TheEmoji.Type
of this emoji.Methods inherited from interface net.dv8tion.jda.api.utils.data.SerializableData
toData
-
Method Details
-
fromUnicode
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
Creates a reference for a custom emoji with the provided name.- Parameters:
name
- The emoji nameid
- The emoji idanimated
- Whether this emoji is animated- Returns:
- The new emoji instance
- Throws:
IllegalArgumentException
- If the name is null or empty
-
fromCustom
Creates a reference for a custom emoji from the providedCustomEmoji
- Parameters:
emoji
- The emoji instance- Returns:
- The new emoji instance
- Throws:
IllegalArgumentException
- If the emoji is null
-
fromFormatted
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("\uD83D\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
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
TheEmoji.Type
of this emoji.- Returns:
- The
Emoji.Type
-
getName
The name of this emoji.
This will be the unicode characters if this emoji is not ofgetType()
CUSTOM
.- Returns:
- The unicode or custom name
-
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
Formatted string used in messages.
For unicode emoji, this is simplygetName()
. For custom emoji, this will be the mention markdown format<:name:id>
.- Returns:
- The formatted message string
-
formatTo
- Specified by:
formatTo
in interfaceFormattable
-