Jan
Jan

Reputation: 19

Discord Java JDA | which reaction was addet

How can I check, which reaction was added to a message? I want to create a command (!roles) with some reaction and if you click on one, you get a role. I tried like this:

if(event.getReactionEmote().emote == ":salt:") {
    Guild guild = event.getGuild();
    guild.addRoleToMember(event.getMember(), guild.getRoleById("*ROLEID*")).queue();
}

But it does not work.

Upvotes: 1

Views: 675

Answers (1)

Danny
Danny

Reputation: 842

Use event.getReactionEmote().getEmoji.equals("EMOTE") where "EMOTE" equals the emoji you want.

You may use EmojiTerra to find the correct code for the emoji of your liking. (You can find it at "Emoji - Codes". Use the code for "Java, JavaScript & JSON".)

Example: The correct code for salt is \uD83E\uDDC2.

Upvotes: 2

Related Questions