Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. const discord = require("discord.js");
  2. const botConfig = require("./botconfig.json");
  3.  
  4.  
  5. const fs = require("fs")
  6.  
  7. const active = new Map();
  8.  
  9. const bot = new discord.Client();
  10. bot.commands = new discord.Collection();
  11.  
  12. fs.readdir("./commands/", (err, files) => {
  13.  
  14. if (err) console.log(err);
  15.  
  16. var jsFiles = files.filter(f => f.split(".").pop() === "js");
  17.  
  18. if (jsFiles.length <= 0) {
  19. console.log("Kon geen files vinden");
  20. return;
  21. }
  22.  
  23. jsFiles.forEach((f, i) => {
  24.  
  25.  
  26. var fileGet = require(`./commands/${f}`);
  27. console.log(`De file ${f} is geladen`);
  28.  
  29. bot.commands.set(fileGet.help.name, fileGet);
  30. })
  31.  
  32. });
  33.  
  34. bot.on("ready", async () => {
  35.  
  36. console.log(`${bot.user.username} is online!`);
  37.  
  38. bot.user.setActivity("?help", { type: "LISTENING" });
  39.  
  40. });
  41.  
  42. bot.on("message", async message => {
  43.  
  44. // Als bot bericht stuurt stuur dan return
  45. if (message.author.bot) return;
  46.  
  47. if (message.channel.type === "dm") return;
  48.  
  49. var prefix = botConfig.prefix;
  50.  
  51. var messageArray = message.content.split(" ");
  52.  
  53. var command = messageArray[0];
  54.  
  55. var arguments = messageArray.slice(1);
  56.  
  57. var commands = bot.commands.get(command.slice(prefix.length));
  58.  
  59. var options = {
  60. active: active
  61. }
  62.  
  63. if (commands) commands.run(bot, message, arguments, options);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement