Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const bot = new Discord.Client();
  3. const token = "Secret token";
  4. const prefix = ",";
  5. bot.commands = new Discord.Collection();
  6. const fs = require("fs");
  7.  
  8. fs.readdir("./commands/", (err, files) => {
  9. if (err) console.err(err);
  10. let jsfiles = files.filter(f => f.split(".").pop() === "js");
  11. if (jsfiles.length <= 0) {
  12. console.log("No commands to load");
  13. return;
  14. }
  15.  
  16. console.log(`Loading ${jsfiles.length} commands`);
  17.  
  18. jsfiles.forEach((f, i) => {
  19. let props = require(`./commands/${f}`);
  20. console.log(`${i + 1}: ${f} loaded!`);
  21. bot.commands.set(f, props);
  22. });
  23. });
  24. bot.on("message", message => {
  25. let messageArray = message.content.split(" ");
  26. let args = messageArray.slice(1);
  27.  
  28. let command = messageArray[0];
  29. if (message.content === "ping") {
  30. message.channel.send("pong");
  31. }
  32. });
  33. bot.on("ready", () => {
  34. console.log("S&S Bot is online!");
  35. console.log(bot.commands);
  36. });
  37.  
  38. bot.login(token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement