SHARE
TWEET

Rr

a guest Aug 20th, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require('discord.js');
  2. var rrId
  3. var rrId1
  4. var rrEmoji
  5.  
  6. module.exports = {
  7.   name: 'reactionrole',
  8.   category: "Utility",
  9.   description: 'Setup a reaction role!',
  10.   cooldown: 10,
  11.  
  12.   execute(message, args, db, ref, admin, client) {
  13.  
  14.     const itemQuestions = new Discord.RichEmbed()
  15.     .setColor('0x009fec')
  16.     .setAuthor(message.author.tag, message.author.avatarURL)
  17.     .addField('What channel should the message be in?', 'You have 1 minute to respond')
  18.  
  19.     const itemQuestions2 = new Discord.RichEmbed()
  20.     .setColor('0x009fec')
  21.     .setAuthor(message.author.tag, message.author.avatarURL)
  22.     .addField('React to this message with the emoji.', 'You have 1 minute to react')
  23.     const itemQuestions3 = new Discord.RichEmbed()
  24.     .setColor('0x009fec')
  25.     .setAuthor(message.author.tag, message.author.avatarURL)
  26.     .addField('What should be the message?', 'You have 1 minute to respond')
  27.     const itemQuestions4 = new Discord.RichEmbed()
  28.     .setColor('0x009fec')
  29.     .setAuthor(message.author.tag, message.author.avatarURL)
  30.     .addField('What role do you want me to give to the user?', 'You have 1 minute to respond')
  31.  
  32.       message.channel.send(itemQuestions);
  33.       const collector = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, { time: 60000 });
  34.       console.log('Collector started!')
  35.       collector.on('collect', message1 => {
  36.      if (!message1.mentions.channels.first()) {
  37.         const deleteErrLowe0 = new Discord.RichEmbed()
  38.         .setColor('#DC143C')
  39.         .setAuthor(message1.author.tag, message1.author.avatarURL)
  40.         .addField('Error!', `You need to enter a valid channel!`)
  41.         message1.channel.send(deleteErrLowe0)
  42.     }else {
  43.         rrChannel = message1.mentions.channels.first()
  44.         message1.channel.send(itemQuestions2).then(reactMessage1 => {
  45.  
  46.           rrId1 = reactMessage1
  47.         console.log('Collector finished!')
  48.         collector.stop()
  49.  
  50.         const filter = (reaction, user) => {
  51.           return reaction.emoji.name && user.id === message.author.id;
  52.         };
  53.         console.log('Collector 2 started!')
  54.         rrId1.awaitReactions(filter, { max: 1, time: 10000, errors: ['time'] })
  55.           .then(collected => {
  56.             const reaction = collected.first();
  57.             rrEmoji = reaction.emoji
  58.             message.channel.send(itemQuestions3)
  59.             console.log(rrEmoji)
  60.             console.log('Collector 2 finished!')
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.         const collector3 = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, { time: 60000 });
  68.         console.log('Collector 3 started!')
  69.         collector3.on('collect', message => {
  70.  
  71.           rrMess = message.content
  72.           message.channel.send(itemQuestions4)
  73.           console.log('Collector 3 finished!')
  74.           collector3.stop()
  75.            
  76.  
  77.  
  78.  
  79.  
  80.  
  81.       const collector4 = new Discord.MessageCollector(message.channel, m => m.author.id === message.author.id, { time: 60000 });
  82.       console.log('Collector 4 started!')
  83.       collector4.on('collect', message => {
  84.         if (!message.guild.roles.find(role => role.name === message.content)) {
  85.           const deleteErrLower0 = new Discord.RichEmbed()
  86.           .setColor('#DC143C')
  87.           .setAuthor(message.author.tag, message.author.avatarURL)
  88.           .addField('Error!', `That is not a valid role name!`)
  89.           message.channel.send(deleteErrLower0)
  90.       }else {
  91.         item = message.guild.roles.find(role => role.name === message.content)
  92.  
  93.  
  94.  
  95.  
  96.  
  97.  
  98.  
  99.  
  100.         const addItSuccess = new Discord.RichEmbed()
  101.         .setColor('#7CFC00')
  102.         .setAuthor(message.author.tag, message.author.avatarURL)
  103.         .setTitle('Reaction role added!')
  104.         .addField('Message:', rrMess, false)
  105.         .addField('Role:', `<@&${item.id}>`, false)
  106.         .setTimestamp()
  107.         message.channel.send(addItSuccess)
  108.  
  109.         rrChannel.send(rrMess).then(reactMessage => {
  110.             reactMessage.react(rrEmoji)
  111.             rrId = reactMessage.id
  112.  
  113.        
  114.         db.ref('reactionroles').child(`${rrId}`).set({
  115.           role: `${item.id}`,
  116.  
  117.         })    
  118.         console.log('Collector 4 finished!')
  119.         collector4.stop()
  120.     });
  121.      
  122.            
  123.           }});
  124.         });
  125.       });
  126.       })
  127.  
  128.       .catch(collected => {
  129.         message.reply('you reacted with neither a thumbs up, nor a thumbs down.');
  130.       });
  131.       }})
  132.  
  133.   }
  134. };
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top