Advertisement
Guest User

Discord Reaction Role

a guest
Dec 16th, 2020
519
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.84 KB | None | 0 0
  1. //This command gives the User the "Member-Role" and removes the "Guest-Role"
  2. //Also only Admins can run this code
  3.  
  4. module.exports = {
  5. name: 'member',
  6. description: "Sets up a reaction role message!",
  7. async execute(message, args, Discord, client) {
  8. const channel = '_ChannelID_';
  9. const yellowTeamRole = message.guild.roles.cache.find(role => role.name === "Member");
  10. const blueTeamRole = message.guild.roles.cache.find(role => role.name === "Gast");
  11.  
  12. const yellowTeamEmoji = '☑️';
  13. //You can only run the command if you re admin
  14. if(message.member.permissions.has("ADMINISTRATOR")){
  15.  
  16. let embed = new Discord.MessageEmbed()
  17. .setColor('#5673f0')
  18. .setTitle('Verifizierung')
  19. .setDescription('Use ☑️ to get Member-Rank\n'
  20. +'INSERT TEXT HERE\n\n')
  21. .setTimestamp();
  22.  
  23. let messageEmbed = await message.channel.send(embed);
  24. messageEmbed.react(yellowTeamEmoji);
  25.  
  26. client.on('messageReactionAdd', async (reaction, user) => {
  27. if (reaction.message.partial) await reaction.message.fetch();
  28. if (reaction.partial) await reaction.fetch();
  29. if (user.bot) return;
  30. if (!reaction.message.guild) return;
  31.  
  32. if (reaction.message.channel.id == channel) {
  33. if (reaction.emoji.name === yellowTeamEmoji) {
  34. await reaction.message.guild.members.cache.get(user.id).roles.add(yellowTeamRole);
  35. await reaction.message.guild.members.cache.get(user.id).roles.remove(blueTeamRole);
  36. }
  37. } else {
  38. return;
  39. }
  40.  
  41. });
  42.  
  43. client.on('messageReactionRemove', async (reaction, user) => {
  44.  
  45. if (reaction.message.partial) await reaction.message.fetch();
  46. if (reaction.partial) await reaction.fetch();
  47. if (user.bot) return;
  48. if (!reaction.message.guild) return;
  49.  
  50.  
  51. if (reaction.message.channel.id == channel) {
  52. if (reaction.emoji.name === yellowTeamEmoji) {
  53. await reaction.message.guild.members.cache.get(user.id).roles.remove(yellowTeamRole);
  54. await reaction.message.guild.members.cache.get(user.id).roles.add(blueTeamRole);
  55. }
  56.  
  57. } else {
  58. return;
  59. }
  60. });
  61. } else(message.reply("You have no permissions!"));
  62. }
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement