Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const discord = require('discord.js');
  2. const prefix = '$';
  3. const commands = ["help", "hello", "joke", "GAMER GOD AWARD", "spam"];
  4. const client = new discord.Client();
  5.  
  6. client.on('ready', () => {
  7.     client.user.setGame('Do $help');
  8.     client.user.setStatus('online');
  9.     console.log("BOT STARTED!");
  10. });
  11.  
  12. for (i = 0; i < commands.length; i++) {
  13.     commands[i] = prefix + commands[i];
  14. }
  15. let gamergodchosen = 0;
  16. let gamergod = "";
  17.  
  18. client.on('message', (message) => {
  19.     if (message.author.bot) return;
  20.  
  21.  
  22.     if (message.content === commands[0]) {
  23.         let e = "Here is a list of commands: \n";
  24.         for (i = 0; i < commands.length; i++) {
  25.             e += (i != (commands.length - 1)) ? commands[i] + "\n" : commands[i];
  26.         }
  27.         message.reply(e);
  28.     }
  29.  
  30.  
  31.     if (message.content === commands[1]) {
  32.         message.reply('hello! :smile:');
  33.     }
  34.  
  35.  
  36.     if (message.content === commands[2]) {
  37.         let jsonjokes = require('./jokes.json');
  38.         let rn = Math.floor(Math.random() * jsonjokes.jokes.length);
  39.         message.reply(jsonjokes.jokes[rn]);
  40.     }
  41.  
  42.  
  43.     if (message.content === commands[3]) {
  44.         //You have been deemed a Gamer God
  45.         if (gamergodchosen === 0) {
  46.             message.reply("YOU HAVE BEEN DEEMED __*THE GAMER GOD*__! **YOU WILL ONLY SEE THIS ONCE!** :trophy:");
  47.             gamergodchosen = 1;
  48.             gamergod = message.author;
  49.         }else{
  50.             message.reply('Gamer God has already been claimed by ' + gamergod + '.');
  51.         }
  52.     }
  53.  
  54.  
  55.     let spam = message.content.split(' ');
  56.  
  57.     if (spam[0] === commands[4]) {
  58.         if (spam[1] && spam[2]) {
  59.             let times = Number(spam[1]).toFixed(0);
  60.             if (isNaN(parseFloat(times))) {
  61.                 message.reply('Incorrect format. Command should be run like this: ' + commands[4] + ' [#] [message]');
  62.                 return;
  63.             }
  64.             if (times > 100) {
  65.                 message.reply('Number is larger than 100.');
  66.                 return;
  67.             }
  68.             if (times < 1) {
  69.                 message.reply('Number is less than 1.');
  70.                 return;
  71.             }
  72.             let msg = message.content.slice(spam[0].length + spam[1].length + 2, message.content.length);
  73.             function doSetTimeout(){
  74.                 setTimeout(function(){
  75.                     message.channel.send(msg);
  76.                 }, 750);
  77.             }
  78.             for (i = 0; i < times; i++) {
  79.                 message.channel.startTyping();
  80.                 doSetTimeout();
  81.                 message.channel.stopTyping();
  82.             }
  83.         } else {
  84.             message.reply('Incorrect format. Command should be run like this: ' + commands[4] + ' [#] [message]');
  85.         }
  86.     }
  87.  
  88.  
  89.  
  90. });
  91.  
  92. client.login('my_token');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement