1

I'm currently working on a bot with discord4j where I want to add a reaction(emoji) to a message. But i have no clue, how to use the addReaction() method and every example i find is using an older version. In earlier versions of dicord4j you could give a string of the unicode representation of the emoji as the parameter, but now it just takes in an object of the type ReactionEmoji. I looked at its methods nothing really makes sense except the ReactionEmoji.unicode(String raw) but then i get the error-message "unknown emoji". As input of the string i tried the unicode, the actual emoji itself, and i went into debug mode, added a reaction to a message, then took the reaction in debug mode, and copied the raw value of the reaction, pasted it as the input parameter of the unicode() mehtod , but it still didn't recognize it as an emoji. Is there some documentation i can't find? My code :

Message msg = channel.createMessage("Test").block();
msg.addReaction("U+2B06").block();
Minn
  • 5,688
  • 2
  • 15
  • 42
jonas
  • 164
  • 1
  • 11

2 Answers2

4

You have to use a unicode escape instead:

channel.createMessage("Test")
       .flatMap(msg -> msg.addReaction(ReactionEmoji.unicode("\u2B06")))
       .subscribe();

For documentation refer to addReaction and ReactionEmoji

Minn
  • 5,688
  • 2
  • 15
  • 42
  • I tried using this to make a reactionAddEvent and Im getting compile errors. https://stackoverflow.com/questions/65767618/discord4j-no-instances-of-type-variables-r-exist-so-that-void-conforms-to-m – Potion Jan 18 '21 at 03:22
0

For multiple reactions

 channel.createMessage("Test").flatMap(msg -> 
 msg.addReaction(ReactionEmoji.unicode(""))
                    .then(msg.addReaction(ReactionEmoji.unicode(""))))
.subscribe();