PB_PhenixH

reactionrole.js

Feb 13th, 2021
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. module.exports = {
  2. name: 'reactionrole',
  3. description: "Sets up a reaction role message!",
  4. async execute(message, args, Discord, client) {
  5. const channel = 'verify';
  6. const yellowTeamRole = message.guild.roles.cache.find(role => role.name === "Verified");
  7. const blueTeamRole = message.guild.roles.cache.find(role => role.name === "UnVerified");
  8.  
  9. const yellowTeamEmoji = ':white_check_mark:';
  10. const blueTeamEmoji = ':x:';
  11.  
  12. let embed = new Discord.MessageEmbed()
  13. .setColor('#e42643')
  14. .setTitle('Do you accept the rules?')
  15. .setDescription('Choose if you do.\n\n'
  16. + `${yellowTeamEmoji} if you do accept.\n`
  17. + `${blueTeamEmoji} if you do not accept`);
  18.  
  19. let messageEmbed = await message.channel.send(embed);
  20. messageEmbed.react(yellowTeamEmoji);
  21. messageEmbed.react(blueTeamEmoji);
  22.  
  23. client.on('messageReactionAdd', async (reaction, user) => {
  24. if (reaction.message.partial) await reaction.message.fetch();
  25. if (reaction.partial) await reaction.fetch();
  26. if (user.bot) return;
  27. if (!reaction.message.guild) return;
  28.  
  29. if (reaction.message.channel.id == channel) {
  30. if (reaction.emoji.name === yellowTeamEmoji) {
  31. await reaction.message.guild.members.cache.get(user.id).roles.add(yellowTeamRole);
  32. }
  33. if (reaction.emoji.name === blueTeamEmoji) {
  34. await reaction.message.guild.members.cache.get(user.id).roles.add(blueTeamRole);
  35. }
  36. } else {
  37. return;
  38. }
  39.  
  40. });
  41.  
  42. client.on('messageReactionRemove', async (reaction, user) => {
  43.  
  44. if (reaction.message.partial) await reaction.message.fetch();
  45. if (reaction.partial) await reaction.fetch();
  46. if (user.bot) return;
  47. if (!reaction.message.guild) return;
  48.  
  49.  
  50. if (reaction.message.channel.id == channel) {
  51. if (reaction.emoji.name === yellowTeamEmoji) {
  52. await reaction.message.guild.members.cache.get(user.id).roles.remove(yellowTeamRole);
  53. }
  54. if (reaction.emoji.name === blueTeamEmoji) {
  55. await reaction.message.guild.members.cache.get(user.id).roles.remove(blueTeamRole);
  56. }
  57. } else {
  58. return;
  59. }
  60. });
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment