Advertisement
Templuzy

Untitled

Feb 2nd, 2021
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const fs = require('fs');
  2.  
  3. module.exports = (client, Discord) =>{
  4.     const load_dir = (dirs) =>{
  5.         const event_files = fs.readdirSync(`./events/${dirs}`).filter(file => file.endsWith('.js'));
  6.         for(const file of event_files){
  7.             const event = require(`../events/${dirs}/${file}`);
  8.             const event_name = file.split('.')[0];
  9.             client.on(event_name, event.bind(null, Discord, client));
  10.         }
  11.     }
  12.  
  13.     ['client', 'guild'].forEach(e => load_dir(e));
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement