coeragames

Untitled

Feb 19th, 2021
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. const Discord = require("discord.js");
  2. const Client = new Discord.Client();
  3. const prefix = "/";
  4. const fs = require("fs");
  5.  
  6.  
  7. Client.commands = new Discord.Collection();
  8. const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
  9. for(const file of commandFiles){
  10. const command = require(`./commands/${file}`);
  11. Client.commands.set(command.name, command)
  12. }
  13.  
  14.  
  15. Client.on("message", message => {
  16. const args = message.content.slice(prefix.length).trim().split(/ +/);
  17. const command = args.shift().toLowerCase();
  18. if(!Client.commands.has(command)) return;
  19. try{
  20. Client.commands.get(command).execute(message, args, Client);
  21. }catch(error){
  22. console.error(error);
  23. message.reply("Une erreur est survenue lors de l'execution de la commande " + error);
  24. }
  25. });
Advertisement
Add Comment
Please, Sign In to add comment