Adding roles based on reactions

时间:2019-04-17 01:55:57

标签: javascript discord discord.js

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.

1 个答案:

答案 0 :(得分:1)

您可以使用messageReactionAdd事件来实现此目的:

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