Advertisement
Guest User

Code Command Handler

a guest
Dec 9th, 2019
1,666
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bot.commands = new Discord.Collection();
  2.  
  3. fs.readdir("./commands/", (err, files) =>{
  4.     if(err) console.log(err);
  5.  
  6.     var jsFiles = files.filter(f => f.split(".").pop() === "js");
  7.     if(jsFiles.length <= 0){
  8.         console.log("Aucun fichier de commande !")
  9.         return;
  10.     }
  11.     jsFiles.forEach((f,i) =>{
  12.         var fileGet = require("./commands/" + f);
  13.         console.log("Fichier de commande " + f + " récupéré avec succès !")
  14.         bot.commands.set(fileGet.help.name, fileGet)
  15.     });
  16. });
  17.  
  18. bot.on("ready", async () =>{
  19.     console.log(" ")
  20.     console.log("Connecté en tant que : " + bot.user.tag)
  21.     bot.user.setActivity("!help | TutoBot", {type: "PLAYING"});
  22. });
  23.  
  24. bot.on("message", message =>{
  25.     if(message.author.bot) return;
  26.     if(message.channel.type === "dm") return;
  27.  
  28.     var prefix = config.prefix;
  29.     var messageArray = message.content.split(" ");
  30.     var command = messageArray[0];
  31.     var args = messageArray.slice(1)
  32.     var commands = bot.commands.get(command.slice(prefix.length))
  33.     if(commands) commands.run(bot, message, args);
  34. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement