Facebook
From Kiani, 1 Month ago, written in JavaScript.
Embed
Download Paste or View Raw
Hits: 56
  1. const botconfig = require("./botconfig.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.   let jsfile = files.filter(f => f.split(".").pop() === "js")
  11.   if(jsfile.length <= 0){
  12.     console.log("Kan de commands niet vinden");
  13.     return;
  14.   }
  15.  
  16.   jsfile.forEach((f, i) =>{
  17.     let props = require(`./commands/${f}`);
  18.     console.log(`${f} is geladen!`);
  19.     bot.commands.set(props.help.name, props);
  20.   });
  21. });
  22.  
  23. bot.on("ready", async () => {
  24.   console.log(`${bot.user.username} is online !`);
  25.   bot.user.setActivity("-help | Flury Community ", {type: "WATCHING"});
  26.  
  27. });
  28.  
  29. bot.on("message", async message => {
  30.   if(message.author.bot) return;
  31.   if(message.channel.type === "dm") return;
  32.  
  33.   let prefix = botconfig.prefix;
  34.   if (!message.content.startsWith(prefix)) return;
  35.   let messageArray = message.content.split(" ");
  36.   let cmd = messageArray[0];
  37.   let args = messageArray.slice(1);
  38.   let commandfile = bot.commands.get(cmd.slice(prefix.length));
  39.   if(commandfile) commandfile.run(bot,message,args);
  40.  
  41. });
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48. bot.login(botconfig.token);