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();

2 Answers 2

5

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

1
1

For multiple reactions

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.