ajoute messageCreate

This commit is contained in:
VALOU3336
2024-02-14 08:19:27 +01:00
parent 7469ee4736
commit 576f5eb05b
6 changed files with 86 additions and 24 deletions
+21 -18
View File
@@ -2,22 +2,25 @@ 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);
client.on(event.name, (...args) => event.run(...args, client));
console.log(`Event ${event.name} loaded`);
count++;
}
});
}
loadEvents('../events');
console.log(`Event => ${count} chargé sur le bot`)
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));
console.log(`Event ${event.name} loaded`);
count++;
} else {
console.error(`Event ${event.name} does not have an execute method.`);
}
}
});
}
loadEvents('../events');
console.log(`Event => ${count} chargé sur le bot`)
}