Package net.dv8tion.jda.api.entities
Class Emoji
- java.lang.Object
-
- net.dv8tion.jda.api.entities.Emoji
-
- All Implemented Interfaces:
java.util.Formattable,IMentionable,ISnowflake,SerializableData
public class Emoji extends java.lang.Object implements SerializableData, IMentionable
Represents a Discord Emoji.
This can either beunicodeorcustom.If this emoji is unicode, then
getIdLong()will be0andISnowflake.getTimeCreated()will be constant at 2015.- See Also:
getName(),getAsMention()
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object obj)static EmojifromData(DataObject emoji)Parses the provided JSON representation to an emoji instance.static EmojifromEmote(java.lang.String name, long id, boolean animated)Creates an emoji with the provided name.static EmojifromEmote(Emote emote)Creates an emoji from the providedEmotestatic EmojifromMarkdown(java.lang.String code)Parses the provided markdown formatting to an Emoji instance.static EmojifromUnicode(java.lang.String code)Creates an emoji with the provided unicode.java.lang.StringgetAsMention()Retrieve a Mention for this Entity.longgetIdLong()The Snowflake id of this entity.java.lang.StringgetName()The name of this emoji.inthashCode()booleanisAnimated()Whether this emote is animated.booleanisCustom()Whether this is a custom emote from a Guild.booleanisUnicode()Whether this emoji is a standard unicode emoji.DataObjecttoData()SerializedDataObjectfor this object.java.lang.StringtoString()-
Methods inherited from interface net.dv8tion.jda.api.entities.IMentionable
formatTo
-
Methods inherited from interface net.dv8tion.jda.api.entities.ISnowflake
getId, getTimeCreated
-
-
-
-
Method Detail
-
getName
@Nonnull public java.lang.String getName()
The name of this emoji.
This will be the unicode characters if this emoji is notcustom.- Returns:
- The unicode or custom name
-
getIdLong
public long getIdLong()
Description copied from interface:ISnowflakeThe Snowflake id of this entity. This is unique to every entity and will never change.- Specified by:
getIdLongin interfaceISnowflake- Returns:
- Long containing the Id.
-
isAnimated
public boolean isAnimated()
Whether this emote is animated.- Returns:
- True, if this emote is animated
-
isUnicode
public boolean isUnicode()
Whether this emoji is a standard unicode emoji.
This meansgetName()returns the unicode characters of this emoji andISnowflake.getId()returns 0.- Returns:
- True, if this emoji is standard unicode
-
isCustom
public boolean isCustom()
Whether this is a custom emote from a Guild.- Returns:
- True, if this is a custom emote
-
fromUnicode
@Nonnull public static Emoji fromUnicode(@Nonnull java.lang.String code)
Creates an emoji with the provided unicode.
This has to be the unicode characters rather than the emoji name.- Parameters:
code- The unicode characters, or codepoint notation such as"U+1f649"- Returns:
- The new emoji instance
- Throws:
java.lang.IllegalArgumentException- If the code is null or empty
-
fromEmote
@Nonnull public static Emoji fromEmote(@Nonnull java.lang.String name, long id, boolean animated)
Creates an emoji with the provided name.- Parameters:
name- The emote nameid- The emote idanimated- Whether this emote is animated- Returns:
- The new emoji instance
- Throws:
java.lang.IllegalArgumentException- If the name is null or empty
-
fromEmote
@Nonnull public static Emoji fromEmote(@Nonnull Emote emote)
Creates an emoji from the providedEmote- Parameters:
emote- The emote instance- Returns:
- The new emoji instance
- Throws:
java.lang.IllegalArgumentException- If the emote is null
-
fromMarkdown
@Nonnull public static Emoji fromMarkdown(@Nonnull java.lang.String code)
Parses the provided markdown formatting to an Emoji instance.Example
// animated custom emoji parseMarkdown("<a:dance:123456789123456789>"); // not animated custom emoji parseMarkdown("<:dog:123456789123456789>"); // unicode emoji, escape codes parseMarkdown("😃"); // unicode emoji parseMarkdown("😃");- Parameters:
code- The code to parse- Returns:
- The emoji instance
- Throws:
java.lang.IllegalArgumentException- If the provided code is null or empty
-
fromData
@Nonnull public static Emoji 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
-
toData
@Nonnull public DataObject toData()
Description copied from interface:SerializableDataSerializedDataObjectfor this object.- Specified by:
toDatain interfaceSerializableData- Returns:
DataObject
-
getAsMention
@Nonnull public java.lang.String getAsMention()
Description copied from interface:IMentionableRetrieve a Mention for this Entity. For the publicRole(@everyone), this will return the literal string"@everyone".- Specified by:
getAsMentionin interfaceIMentionable- Returns:
- A resolvable mention.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-