Okna
Okna

Reputation: 29

Adding roles based on reactions

I want to make a bot that gives roles when using reaction but I'm really stuck, I can't find anything on the documentation so I need help.
I already did this:

if (command == "role")
  message.channel.send("Click on :emoji1: to get role1, :emoji2: to get role2 and :emoji3: to get role3.")
  .then(sentMessage => {
    sentMessage.react(":emoji1:")
    sentMessage.react(":emoji2:")
    sentMessage.react(":emoji3:")
  });

It works just fine but I can't find how to add role when clicking a reaction.

Upvotes: 0

Views: 370

Answers (1)

Zooly
Zooly

Reputation: 4787

You can achieve this by using the messageReactionAdd event:

client.on('messageReactionAdd', (reaction, user) => {
  reaction.message.guild.member(user).addRole('yourRole');
});

Upvotes: 2

Related Questions