Advertisement
ninja-gen

Shutdown Command

Oct 27th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. exports.run = (client, message, args) => {
  2.   if (message.author.id !== "486659270876856362") return message.reply('You do not have the permission to use this command!');
  3.  
  4.   message.delete().catch();
  5.   message.channel.send('Are you sure you want to shut me down?\n\nReply with \`cancel\` to **abort** the shutdown. The shutdown will self-abort in 30 seconds.');
  6.   return message.channel.awaitMessages(m => m.author.id === message.author.id, {
  7.     'errors': ['time'],
  8.     'max': 1,
  9.     time: 30000
  10.   }).then(resp => {
  11.     if (!resp) return;
  12.     resp = resp.array()[0];
  13.     let validAnswers = ['yes', 'y', 'no', 'n', 'cancel'];
  14.     if (validAnswers.includes(resp.content)) {
  15.       if (resp.content === 'cancel' || resp.content === 'no' || resp.content === 'n') {
  16.         return message.channel.send('**Shutdown Aborted.**');
  17.       } else if (resp.content === 'yes' || resp.content === 'y') {
  18.         message.channel.send("Restarting & Updating The Process :wave:")
  19.         client.destroy().then(() => {
  20.           process.exit();
  21.         }).catch(console.error);
  22.       }
  23.     } else {
  24.       message.channel.send(`Only \`${validAnswers.join('`, `')}\` are valid, please supply one of those.`).catch(()=>console.error);
  25.     }
  26.   }).catch(() => {
  27.     console.error;
  28.     message.channel.send('Shutdown timed out.');
  29.   });
  30. };
  31.  
  32. exports.conf = {
  33.   enabled: true,  
  34.   guildOnly: true,
  35.   aliases: [],
  36.   permLevel: 0
  37. };
  38.  
  39. exports.help = {
  40.   name: 'shutdown',
  41.   description: 'Shutdown the bot.',
  42.   usage: 'shutdown'
  43. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement