Facebook
From Unique Crow, 4 Years ago, written in Plain Text.
This paste is a reply to Untitled from Perl Matamata - view diff
Embed
Download Paste or View Raw
Hits: 250
  1. const config = require('./config.json')
  2. const Discord = require("discord.js");
  3. const fs = require("fs");
  4. const bot = new Discord.Client({disableEveryone: true});
  5. bot.commands = new Discord.Collection();
  6.  
  7. fs.readdir("./commands/", (err, files) => {
  8.  
  9.   if(err) console.log(err);
  10.  
  11.   let jsfile = files.filter(f => f.split(".").pop() === "js")
  12.   if(jsfile.length <= 0){
  13.     console.log("Couldn't find commands.");
  14.     return;
  15.   }
  16.  
  17.   jsfile.forEach((f, i) =>{
  18.     let props = require(`./commands/${f}`);
  19.     console.log(`${f} loaded!`);
  20.     bot.commands.set(props.help.name, props);
  21.   });
  22.  
  23. });
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. bot.on("ready", async () => {
  31.   console.log(`${bot.user.username} is online on ${bot.guilds.size} servers!`);
  32.     setInterval(function() {
  33.       request.get(serverQuery)
  34.           .then(res => {
  35.             let Statuses = [`c!help | Bot by Stainlqss | ステンレス#2322`, `Hosted By NitroSRV.us`]
  36.             let status = Statuses[Math.floor(Math.random()*Statuses.length)];
  37.               bot.user.setActivity(status, {
  38.                   type: 'PLAYING'
  39.               })
  40.           });
  41.   }, 1000);
  42.    
  43.  
  44.  
  45.  
  46.  
  47.  
  48. });
  49.  
  50. bot.on("message", async message => {
  51.   if(message.author.bot) return;
  52.   if(message.channel.type === "dm") return;
  53.  
  54.   let prefix = config.prefix;
  55.   let messageArray = message.content.split(" ");
  56.   let cmd = messageArray[0];
  57.   let args = messageArray.slice(1);
  58.  
  59.   let commandfile = bot.commands.get(cmd.slice(prefix.length));
  60.   if(commandfile) commandfile.run(bot,message,args);
  61.  
  62.  
  63. });
  64.  
  65.                                                                                            
  66. bot.on('guildMemberAdd', async member => {
  67.     if (member.user.bot) return;
  68.  
  69.  
  70. });
  71.  
  72.  
  73. bot.login(config.token);
  74.