mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-05 13:51:57 +02:00
init base
This commit is contained in:
+21
-20
@@ -1,23 +1,24 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
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 the cache for this command file
|
||||
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++;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
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`)
|
||||
}
|
||||
loadEvents("../events");
|
||||
console.log(`Event => ${count} chargé sur le bot\n`);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user