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 for message reactions, provides factory methods such as unicode(String) and others to generate reactions.
  • Constructor Details

    • ReactionEmoji

      public ReactionEmoji()
  • Method Details

    • custom

      public static ReactionEmoji.Custom custom(GuildEmoji emoji)
      Constructs a ReactionEmoji using information from a known 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 a ReactionEmoji 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 a ReactionEmoji 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 a ReactionEmoji 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 a ReactionEmoji 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 a ReactionEmoji from a ReactionData representation.
      Parameters:
      data - the ReactionData wrapper.
      Returns:
      a reaction emoji using the given information.
    • of

      public static ReactionEmoji of(discord4j.discordjson.json.EmojiData data)
      Constructs a ReactionEmoji from a EmojiData representation.
      Parameters:
      data - the EmojiData wrapper.
      Returns:
      a reaction emoji using the given information.
    • asFormat

      public abstract String asFormat()
      Gets the formatted version of this emoji (i.e., to display in the client).
      Returns:
      The formatted version of this emoji (i.e., to display in the client).
    • asCustomEmoji

      public Optional<ReactionEmoji.Custom> asCustomEmoji()
      Gets this emoji as downcasted to a custom reaction emoji.
      Returns:
      This emoji downcasted to a custom emoji, if possible.
    • asUnicodeEmoji

      public Optional<ReactionEmoji.Unicode> asUnicodeEmoji()
      Gets this emoji downcasted to a unicode reaction emoji.
      Returns:
      This emoji downcasted to a unicode emoji, if possible.
    • asEmojiData

      public abstract discord4j.discordjson.json.EmojiData asEmojiData()
      Converts this ReactionEmoji to a EmojiData.
      Returns:
      An EmojiData for this emoji.