Advertisement
dfhfjjfgjfsfeedgf

Untitled

Jan 6th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const Config = require("./config.json");
  3. const Token = require("./token.json");
  4. const fs = require("fs");
  5.  
  6. const bot = new Discord.Client({disableEveryone: true});
  7. bot.commands = new Discord.Collection();
  8.  
  9. fs.readdir("./commands/", (err, files) =>{
  10. if(err) console.log(err);
  11. let jsfile = files.filter(f => f.split(".").pop() === "js");
  12. if(jsfile.length <= 0){
  13. console.log("could not find a command");
  14. return;
  15. }
  16.  
  17. jsfile.forEach((f, i) =>{
  18. let props = require(`./commands/${f}`);
  19. console.log(`${f} has loaded!`);
  20. bot.commands.set(props.help.name, props);
  21. });
  22. });
  23.  
  24.  
  25. bot.on("ready", async () =>{
  26. console.log(`${bot.user.username} is online! And ready to serve discord!! And it's running on ${bot.guilds.size} servers!`);
  27. bot.user.setActivity("In development....", {type: "PLAYING"});
  28. })
  29.  
  30.  
  31. bot.on("message", async message => {
  32. if(message.author.bot) return;
  33. if(message.channel.type === "dm") return;
  34. let prefix = Config.prefix;
  35. let msgArray = message.content.split(" ");
  36. let cmd = msgArray[0];
  37. let args = msgArray.slice(1);
  38. let cmdFile = bot.commands.get(cmd.slice(prefix.length));
  39. if(cmdFile) cmdFile.run(bot, message, args);
  40. let commandFile = bot.commands.get(cmd.slice(prefix.length))
  41. if(commandFile) commandFile.run(bot, message,args);
  42.  
  43.  
  44. })
  45.  
  46. bot.login(Token.token);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement