Package discord4j.core.object.reaction
Class ReactionEmoji
- java.lang.Object
-
- discord4j.core.object.reaction.ReactionEmoji
-
- Direct Known Subclasses:
ReactionEmoji.Custom
,ReactionEmoji.Unicode
public abstract class ReactionEmoji extends Object
An emoji used formessage reactions
, provides factory methods such asunicode(String)
and others to generate reactions.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ReactionEmoji.Custom
static class
ReactionEmoji.Unicode
-
Constructor Summary
Constructors Constructor Description ReactionEmoji()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Optional<ReactionEmoji.Custom>
asCustomEmoji()
Gets this emoji as downcasted toa custom reaction emoji
.abstract discord4j.discordjson.json.EmojiData
asEmojiData()
Converts thisReactionEmoji
to aEmojiData
.Optional<ReactionEmoji.Unicode>
asUnicodeEmoji()
Gets this emoji downcasted toa unicode reaction emoji
.static ReactionEmoji.Unicode
codepoints(String... codepoints)
Constructs aReactionEmoji
for a unicode emoji.static ReactionEmoji.Custom
custom(Snowflake id, String name, boolean isAnimated)
Constructs aReactionEmoji
for a custom emoji using the given information.static ReactionEmoji.Custom
custom(GuildEmoji emoji)
Constructs aReactionEmoji
using information from aknown guild emoji
.static ReactionEmoji
of(discord4j.discordjson.json.EmojiData data)
Constructs aReactionEmoji
from aEmojiData
representation.static ReactionEmoji
of(discord4j.discordjson.json.ReactionData data)
Constructs aReactionEmoji
from aReactionData
representation.static ReactionEmoji
of(Long id, String name, boolean isAnimated)
Constructs aReactionEmoji
for generic emoji information.static ReactionEmoji.Unicode
unicode(String raw)
Constructs aReactionEmoji
for a unicode emoji.
-
-
-
Method Detail
-
custom
public static ReactionEmoji.Custom custom(GuildEmoji emoji)
Constructs aReactionEmoji
using information from aknown guild emoji
.- Parameters:
emoji
- The guild emoji from which to take information.- Returns:
- A reaction emoji using information from the given guild emoji.
-
custom
public static ReactionEmoji.Custom custom(Snowflake id, String name, boolean isAnimated)
Constructs aReactionEmoji
for a custom emoji using the given information.- Parameters:
id
- The ID of the custom emoji.name
- The name of the custom emoji.isAnimated
- Whether the custom emoji is animated.- Returns:
- A reaction emoji using the given information.
-
unicode
public static ReactionEmoji.Unicode unicode(String raw)
Constructs aReactionEmoji
for a unicode emoji.The string argument to this method should be the exact UTF-16 encoded string of the desired emoji. For example,
ReactionEmoji.unicode("\u2764") // "heart" ReactionEmoji.unicode("\uD83D\uDE00") // "grinning face" ReactionEmoji.unicode("\uD83D\uDC68\u200D\uD83E\uDDB0") // "man: red hair"
A full list of emoji can be found here.This method does not accept the "U+" notation for codepoints. For that, use
codepoints(String...)
.- Parameters:
raw
- The raw unicode string for the emoji.- Returns:
- A reaction emoji using the given information.
-
codepoints
public static ReactionEmoji.Unicode codepoints(String... codepoints)
Constructs aReactionEmoji
for a unicode emoji.The argument(s) to this method should use the "U+" notation for codepoints. For example,
ReactionEmoji.codepoints("U+2764") // "heart" ReactionEmoji.codepoints("U+1F600") // "grinning face" ReactionEmoji.codepoints("U+1F468", "U+200D", "U+1F9B0") // "man: red hair"
A full list of emoji can be found here.- Parameters:
codepoints
- The codepoints that make up the emoji.- Returns:
- A reaction emoji using the given information.
-
of
public static ReactionEmoji of(@Nullable Long id, String name, boolean isAnimated)
Constructs aReactionEmoji
for generic emoji information.- Parameters:
id
- The ID of the custom emoji OR null if the emoji is a unicode emoji.name
- The name of the custom emoji OR the raw unicode string for the emoji.isAnimated
- Whether the emoji is animated OR false if the emoji is a unicode emoji.- Returns:
- A reaction emoji using the given information.
-
of
public static ReactionEmoji of(discord4j.discordjson.json.ReactionData data)
Constructs aReactionEmoji
from aReactionData
representation.- Parameters:
data
- theReactionData
wrapper.- Returns:
- a reaction emoji using the given information.
-
of
public static ReactionEmoji of(discord4j.discordjson.json.EmojiData data)
Constructs aReactionEmoji
from aEmojiData
representation.- Parameters:
data
- theEmojiData
wrapper.- Returns:
- a reaction emoji using the given information.
-
asCustomEmoji
public Optional<ReactionEmoji.Custom> asCustomEmoji()
Gets this emoji as downcasted toa custom reaction emoji
.- Returns:
- This emoji downcasted to a custom emoji, if possible.
-
asUnicodeEmoji
public Optional<ReactionEmoji.Unicode> asUnicodeEmoji()
Gets this emoji downcasted toa unicode reaction emoji
.- Returns:
- This emoji downcasted to a unicode emoji, if possible.
-
asEmojiData
public abstract discord4j.discordjson.json.EmojiData asEmojiData()
Converts thisReactionEmoji
to aEmojiData
.- Returns:
- An
EmojiData
for this emoji.
-
-