Advertisement
Guest User

Discordjs Bot Code

a guest
Feb 23rd, 2021
279
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module.exports = {
  2.   name: "color_role",
  3.   description: "Setup color role reaction message and reactions",
  4.   async execute(message, args, Discord, client) {
  5.     const channel = "811706365558128721";
  6.  
  7.     const amberRole = message.guild.roles.cache.find(
  8.       (role) => role.name === "Amber"
  9.     );
  10.     const blueRole = message.guild.roles.cache.find(
  11.       (role) => role.name === "Blue"
  12.     );
  13.     const cyanRole = message.guild.roles.cache.find(
  14.       (role) => role.name === "Cyan"
  15.     );
  16.     const greenRole = message.guild.roles.cache.find(
  17.       (role) => role.name === "Green"
  18.     );
  19.     const pinkRole = message.guild.roles.cache.find(
  20.       (role) => role.name === "Pink"
  21.     );
  22.     const purpleRole = message.guild.roles.cache.find(
  23.       (role) => role.name === "Purple"
  24.     );
  25.     const redRole = message.guild.roles.cache.find(
  26.       (role) => role.name === "Red"
  27.     );
  28.     const deepOrangeRole = message.guild.roles.cache.find(
  29.       (role) => role.name === "DeepOrange"
  30.     );
  31.     const brownRole = message.guild.roles.cache.find(
  32.       (role) => role.name === "Brown"
  33.     );
  34.     const deepPurpleRole = message.guild.roles.cache.find(
  35.       (role) => role.name === "DeepPurple"
  36.     );
  37.     const indigoRole = message.guild.roles.cache.find(
  38.       (role) => role.name === "Indigo"
  39.     );
  40.     const lightBlueRole = message.guild.roles.cache.find(
  41.       (role) => role.name === "LightBlue"
  42.     );
  43.     const tealRole = message.guild.roles.cache.find(
  44.       (role) => role.name === "Teal"
  45.     );
  46.     const lightGreenRole = message.guild.roles.cache.find(
  47.       (role) => role.name === "LightGreen"
  48.     );
  49.     const limeRole = message.guild.roles.cache.find(
  50.       (role) => role.name === "Lime"
  51.     );
  52.     const yellowRole = message.guild.roles.cache.find(
  53.       (role) => role.name === "Yellow"
  54.     );
  55.     const orangeRole = message.guild.roles.cache.find(
  56.       (role) => role.name === "Orange"
  57.     );
  58.  
  59.     const amberEmoji = "811153480969617469";
  60.     const blueEmoji = "811153495092363315";
  61.     const cyanEmoji = "811153522854199317";
  62.     const greenEmoji = "811153563714846741";
  63.     const pinkEmoji = "811153647089352705";
  64.     const purpleEmoji = "811153657365790750";
  65.     const redEmoji = "811148706610675723";
  66.     const deepOrangeEmoji = "811153537143930920";
  67.     const brownEmoji = "811153510661750824";
  68.     const deepPurpleEmoji = "811153551937765416";
  69.     const indigoEmoji = "811153575102513203";
  70.     const lightBlueEmoji = "811153587404668928";
  71.     const tealEmoji = "811153679822094397";
  72.     const lightGreenEmoji = "811153604982734879";
  73.     const limeEmoji = "811153617158537256";
  74.     const yellowEmoji = "811153690316242964";
  75.     const orangeEmoji = "811153632619397122";
  76.  
  77.     let embed = new Discord.MessageEmbed()
  78.       .setColor("#e42643")
  79.       .setTitle("Color Role Reaction")
  80.       .setDescription(
  81.         "React to this message with the color emotes below to get a role based on that color. If you want to remove that color role then just click on that same emote again."
  82.       );
  83.  
  84.     let messageEmbed = await message.channel.send(embed);
  85.     let messageId = embed.id;
  86.  
  87.     messageEmbed.react(amberEmoji);
  88.     messageEmbed.react(blueEmoji);
  89.     messageEmbed.react(cyanEmoji);
  90.     messageEmbed.react(greenEmoji);
  91.     messageEmbed.react(pinkEmoji);
  92.     messageEmbed.react(purpleEmoji);
  93.     messageEmbed.react(redEmoji);
  94.     messageEmbed.react(deepOrangeEmoji);
  95.     messageEmbed.react(brownEmoji);
  96.     messageEmbed.react(deepPurpleEmoji);
  97.     messageEmbed.react(indigoEmoji);
  98.     messageEmbed.react(lightBlueEmoji);
  99.     messageEmbed.react(tealEmoji);
  100.     messageEmbed.react(lightGreenEmoji);
  101.     messageEmbed.react(limeEmoji);
  102.     messageEmbed.react(yellowEmoji);
  103.     messageEmbed.react(orangeEmoji);
  104.  
  105.     client.on("messageReactionAdd", async (reaction, user) => {
  106.       if (reaction.message.partial) await reaction.message.fetch();
  107.       if (reaction.partial) await reaction.fetch();
  108.       if (user.bot) return;
  109.       if (!reaction.message.guild) return;
  110.  
  111.       if (reaction.message.channel.id == channel) {
  112.         if (reaction.messsage.id == embed.id) {
  113.           if (reaction.emoji.id === amberEmoji) {
  114.             await reaction.message.guild.members.cache
  115.               .get(user.id)
  116.               .roles.add(amberRole);
  117.           }
  118.           if (reaction.emoji.id === blueEmoji) {
  119.             await reaction.message.guild.members.cache
  120.               .get(user.id)
  121.               .roles.add(blueRole);
  122.           }
  123.           if (reaction.emoji.id === cyanEmoji) {
  124.             await reaction.message.guild.members.cache
  125.               .get(user.id)
  126.               .roles.add(cyanRole);
  127.           }
  128.           if (reaction.emoji.id === greenEmoji) {
  129.             await reaction.message.guild.members.cache
  130.               .get(user.id)
  131.               .roles.add(greenRole);
  132.           }
  133.           if (reaction.emoji.id === pinkEmoji) {
  134.             await reaction.message.guild.members.cache
  135.               .get(user.id)
  136.               .roles.add(pinkRole);
  137.           }
  138.           if (reaction.emoji.id === purpleEmoji) {
  139.             await reaction.message.guild.members.cache
  140.               .get(user.id)
  141.               .roles.add(purpleRole);
  142.           }
  143.           if (reaction.emoji.id === redEmoji) {
  144.             await reaction.message.guild.members.cache
  145.               .get(user.id)
  146.               .roles.add(redRole);
  147.           }
  148.           if (reaction.emoji.id === deepOrangeEmoji) {
  149.             await reaction.message.guild.members.cache
  150.               .get(user.id)
  151.               .roles.add(deepOrangeRole);
  152.           }
  153.           if (reaction.emoji.id === brownEmoji) {
  154.             await reaction.message.guild.members.cache
  155.               .get(user.id)
  156.               .roles.add(brownRole);
  157.           }
  158.           if (reaction.emoji.id === deepPurpleEmoji) {
  159.             await reaction.message.guild.members.cache
  160.               .get(user.id)
  161.               .roles.add(deepPurpleRole);
  162.           }
  163.           if (reaction.emoji.id === indigoEmoji) {
  164.             await reaction.message.guild.members.cache
  165.               .get(user.id)
  166.               .roles.add(indigoRole);
  167.           }
  168.           if (reaction.emoji.id === lightBlueEmoji) {
  169.             await reaction.message.guild.members.cache
  170.               .get(user.id)
  171.               .roles.add(lightBlueRole);
  172.           }
  173.           if (reaction.emoji.id === tealEmoji) {
  174.             await reaction.message.guild.members.cache
  175.               .get(user.id)
  176.               .roles.add(tealRole);
  177.           }
  178.           if (reaction.emoji.id === lightGreenEmoji) {
  179.             await reaction.message.guild.members.cache
  180.               .get(user.id)
  181.               .roles.add(lightGreenRole);
  182.           }
  183.           if (reaction.emoji.id === limeEmoji) {
  184.             await reaction.message.guild.members.cache
  185.               .get(user.id)
  186.               .roles.add(limeRole);
  187.           }
  188.           if (reaction.emoji.id === yellowEmoji) {
  189.             await reaction.message.guild.members.cache
  190.               .get(user.id)
  191.               .roles.add(yellowRole);
  192.           }
  193.           if (reaction.emoji.id === orangeEmoji) {
  194.             await reaction.message.guild.members.cache
  195.               .get(user.id)
  196.               .roles.add(orangeRole);
  197.           }
  198.         }
  199.       } else {
  200.         return;
  201.       }
  202.     });
  203.  
  204.     client.on("messageReactionRemove", async (reaction, user) => {
  205.       if (reaction.message.partial) await reaction.message.fetch();
  206.       if (reaction.partial) await reaction.fetch();
  207.       if (user.bot) return;
  208.       if (!reaction.message.guild) return;
  209.  
  210.       if (reaction.message.channel.id == channel) {
  211.         if (reaction.emoji.id === amberEmoji) {
  212.           await reaction.message.guild.members.cache
  213.             .get(user.id)
  214.             .roles.remove(amberRole);
  215.         }
  216.         if (reaction.emoji.id === blueEmoji) {
  217.           await reaction.message.guild.members.cache
  218.             .get(user.id)
  219.             .roles.remove(blueRole);
  220.         }
  221.         if (reaction.emoji.id === cyanEmoji) {
  222.           await reaction.message.guild.members.cache
  223.             .get(user.id)
  224.             .roles.remove(cyanRole);
  225.         }
  226.         if (reaction.emoji.id === greenEmoji) {
  227.           await reaction.message.guild.members.cache
  228.             .get(user.id)
  229.             .roles.remove(greenRole);
  230.         }
  231.         if (reaction.emoji.id === pinkEmoji) {
  232.           await reaction.message.guild.members.cache
  233.             .get(user.id)
  234.             .roles.remove(pinkRole);
  235.         }
  236.         if (reaction.emoji.id === purpleEmoji) {
  237.           await reaction.message.guild.members.cache
  238.             .get(user.id)
  239.             .roles.remove(purpleRole);
  240.         }
  241.         if (reaction.emoji.id === redEmoji) {
  242.           await reaction.message.guild.members.cache
  243.             .get(user.id)
  244.             .roles.remove(redRole);
  245.         }
  246.         if (reaction.emoji.id === deepOrangeEmoji) {
  247.           await reaction.message.guild.members.cache
  248.             .get(user.id)
  249.             .roles.remove(deepOrangeRole);
  250.         }
  251.         if (reaction.emoji.id === brownEmoji) {
  252.           await reaction.message.guild.members.cache
  253.             .get(user.id)
  254.             .roles.remove(brownRole);
  255.         }
  256.         if (reaction.emoji.id === deepPurpleEmoji) {
  257.           await reaction.message.guild.members.cache
  258.             .get(user.id)
  259.             .roles.remove(deepPurpleRole);
  260.         }
  261.         if (reaction.emoji.id === indigoEmoji) {
  262.           await reaction.message.guild.members.cache
  263.             .get(user.id)
  264.             .roles.remove(indigoRole);
  265.         }
  266.         if (reaction.emoji.id === lightBlueEmoji) {
  267.           await reaction.message.guild.members.cache
  268.             .get(user.id)
  269.             .roles.remove(lightBlueRole);
  270.         }
  271.         if (reaction.emoji.id === tealEmoji) {
  272.           await reaction.message.guild.members.cache
  273.             .get(user.id)
  274.             .roles.remove(tealRole);
  275.         }
  276.         if (reaction.emoji.id === lightGreenEmoji) {
  277.           await reaction.message.guild.members.cache
  278.             .get(user.id)
  279.             .roles.remove(lightGreenRole);
  280.         }
  281.         if (reaction.emoji.id === limeEmoji) {
  282.           await reaction.message.guild.members.cache
  283.             .get(user.id)
  284.             .roles.remove(limeRole);
  285.         }
  286.         if (reaction.emoji.id === yellowEmoji) {
  287.           await reaction.message.guild.members.cache
  288.             .get(user.id)
  289.             .roles.remove(yellowRole);
  290.         }
  291.         if (reaction.emoji.id === orangeEmoji) {
  292.           await reaction.message.guild.members.cache
  293.             .get(user.id)
  294.             .roles.remove(orangeRole);
  295.         }
  296.       } else {
  297.         return;
  298.       }
  299.     });
  300.   },
  301. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement