Files
2024-03-02 14:56:25 +01:00

24 lines
876 B
JavaScript

const fs = require('fs');
const path = require('path');
module.exports = (client) => {
let count = 0;
const loadEvents = (dir) => {
fs.readdirSync(path.join(__dirname, dir)).forEach(file => {
const filePath = path.join(__dirname, dir, file);
if (fs.statSync(filePath).isDirectory()) {
loadEvents(path.join(dir, file));
} else if (file.endsWith('.js')) {
delete require.cache[require.resolve(filePath)];
const event = require(filePath);
if (typeof event.execute === 'function') {
client.on(event.name, (...args) => event.execute(...args, client));
count++;
} else {
}
}
});
}
loadEvents('../events');
console.log(`Event => ${count} chargé sur le bot`)
}