Liam Skinner
Liam Skinner

Reputation: 26

Discord.js Assign a role based off a certain message reaction

I Want it so if a member does a certain reaction to a certain message. it will give them a role. i know how to add a role

let role6 = member.guild.roles.cache.find(role => role.name == "Member");
if(!role6) return;
user.roles.add(role6);

but I'm not sure who to get it to be triggered by a :white_check_mark: reaction to a certain message in a channel. any ideas?

Upvotes: 0

Views: 829

Answers (1)

Lioness100
Lioness100

Reputation: 8412

You can use the messageReactionAdd event, which will emit when someone reacts to a message.

client.on('messageReactionAdd', (reaction, user) => {
 if (reaction.message.id !== 'Message ID') return;
 const role6 = member.guild.roles.cache.find((role) => role.name == 'Member');
 if (!role6) return;
 reaction.guild.member(user).roles.add(role6);
});

Upvotes: 1

Related Questions