Advertisement
vilmodz

index.js Discord

Aug 14th, 2019
573
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const Discord = require('discord.js');
  2. const client = new Discord.Client();
  3. client.commands = new Discord.Collection();
  4. const fs = require('fs');
  5. const vm = require('vm.js')
  6.  
  7. client.on('ready' , () => {
  8.     console.log('Le bot est bien connecté')
  9. })
  10.  
  11. fs.readdir('./commands/', (error, f) => {
  12.     if (error) { return console.error(error); }
  13.         let commandes = f.filter(f => f.split('.').pop() === 'js');
  14.         if (commandes.length <= 0) { return console.log('Aucune commande trouvée !'); }
  15.         commandes.forEach((f) => {
  16.             let commande = require(`./commands/${f}`);
  17.             console.log(`${f} commande chargée !`);
  18.             client.commands.set(commande.help.name, commande);
  19.         });
  20. });
  21.  
  22. fs.readdir('./events/', (error, f) => {
  23.     if (error) { return console.error(error); }
  24.         console.log(`${f.length} events chargés`);
  25.         f.forEach((f) => {
  26.             let events = require(`./events/${f}`);
  27.             let event = f.split('.')[0];
  28.             client.on(event, events.bind(null, client));
  29.         });
  30. });
  31.  
  32. client.login(process.env.TOKEN);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement