Advertisement
Guest User

request.js

a guest
Nov 16th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.39 KB | None | 0 0
  1. const Discord = require("discord.js");
  2.  
  3. module.exports = class request {
  4.     // Command Handler
  5.     constructor() {
  6.         this.name = 'request',
  7.             // Name of command
  8.             this.alias = [''],
  9.             // Alias of Command
  10.             this.usage = 'request';
  11.         // Main Command
  12.     }
  13.  
  14.     run(bot, message, args) {
  15.         // Embed Design
  16.  
  17.         const Embed = new Discord.RichEmbed()
  18.             .setAuthor("New Request Approval")
  19.             .setFooter("Hangout Manager v1.0.0")
  20.             .setDescription("A new user has requested approval to the discord server.\n" +
  21.                 "React with <a:Agree:645279978929258506> to Approve\n" +
  22.                 "React with <a:Disagree:645279979650809856> to Deny.")
  23.             .addField("User ", `<@${message.author.id}>`, true)
  24.             .addField("Id", `${message.author.id}`, true);
  25.  
  26.         // If command is sent outside of #waiting-lobby
  27.         if (message.channel.id != '645302564409311232') {
  28.             message.channel.send(`<@${message.author.id}>, You cannot use this command here.`);
  29.             return;
  30.  
  31.         } else {
  32.             bot.channels.get("645306384975659012").send(Embed).then(m => {
  33.  
  34.                 message.delete();
  35.  
  36.                 // Add reactions
  37.                 m.react('✅').then(() =>
  38.                     m.react('⛔'));
  39.                 // Tell the message author it was sent.
  40.                 message.author.send("I have sent your approval request to admins, Please be patient. <a:PanGLoveP:644305939222102057>");
  41.                 // Start the timer for the wait until it gets the Agree Reaction.
  42.                 const accepted = m.awaitReactions(reaction => reaction.name === 'white_check_mark', { max: 2, time: 10000 }).then((collected1) => {
  43.  
  44.                     if (collected1.first() === 'white_check_mark') {
  45.                         Embed.setDescription("**Status:** Accepted <a:Agree:645279978929258506>");
  46.  
  47.                         message.member.removeRole('645299990654222396');
  48.                         // If they don't have Approved Role, Give it.
  49.                         message.member.addRole('609324765798465546');
  50.  
  51.                         // Tell the Command Author they were accepted.
  52.                         message.author.send('You have been accepted into Ori\'s Hangout! Please read <#608906752175374336> and <#608982522269007885>');
  53.  
  54.                         m.clearReactions();
  55.                         m.edit(Embed);
  56.                     }
  57.                 }).catch(() => message.author.send(`<@${message.author.id}>, Your application did not gain a response after 24 Hours.\nFeel Free to send another application with "!request"`));
  58.                 break;
  59.  
  60.                 // Start the time for the wait until it gets the Disagree Reaction.
  61.                 const denied = m.awaitReactions(reaction => reaction.name === 'no_entry', { max: 2, time: 10000 }).then((collected2) => {
  62.  
  63.                     if (collected2.first() === 'no_entry') {
  64.                         Embed.setDescription("**Status:** Denied <a:Disagree:645279979650809856>");
  65.  
  66.                         message.author.send('You were denied into Ori\'s Hangout. <a:Disagree:645279979650809856>');
  67.                         message.member.kick();
  68.  
  69.                         m.clearReactions();
  70.                         m.edit(Embed);
  71.  
  72.                     }
  73.                 });
  74.             });
  75.         }
  76.     }
  77. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement