mirror of
https://github.com/arthur-pbty/gestion.git
synced 2026-06-04 07:46:36 +02:00
init base
This commit is contained in:
+29
-27
@@ -1,28 +1,30 @@
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
module.exports = (client) => {
|
||||
const loadCommands = (dir) => {
|
||||
let count = 0;
|
||||
fs.readdirSync(path.join(__dirname, dir)).forEach(file => {
|
||||
const filePath = path.join(__dirname, dir, file);
|
||||
if (fs.statSync(filePath).isDirectory()) {
|
||||
count += loadCommands(path.join(dir, file));
|
||||
} else if (file.endsWith('.js')) {
|
||||
try {
|
||||
// Delete the cache for this command file
|
||||
delete require.cache[require.resolve(filePath)];
|
||||
const command = require(filePath);
|
||||
client.commands.set(command.name, command);
|
||||
count++;
|
||||
} catch (error) {
|
||||
console.error(`Failed to load file: ${filePath}`); // Log any errors
|
||||
console.error(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
return count;
|
||||
}
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
|
||||
const totalCommands = loadCommands('../commands');
|
||||
console.log(`Commands => ${totalCommands} commandes préfixées chargées sur le bot`);
|
||||
}
|
||||
module.exports = (client) => {
|
||||
let count = 0;
|
||||
const loadCommands = (dir) => {
|
||||
fs.readdirSync(path.join(__dirname, dir)).forEach((file) => {
|
||||
const filePath = path.join(__dirname, dir, file);
|
||||
if (fs.statSync(filePath).isDirectory()) {
|
||||
count += loadCommands(path.join(dir, file));
|
||||
} else if (file.endsWith(".js")) {
|
||||
try {
|
||||
// Delete the cache for this command file
|
||||
delete require.cache[require.resolve(filePath)];
|
||||
const command = require(filePath);
|
||||
client.commands.set(command.name, command);
|
||||
count++;
|
||||
} catch (error) {
|
||||
console.error(`Failed to load file: ${filePath}\n`, error, '\n');
|
||||
//console.error(`Failed to load file: ${filePath}`); // Log any errors
|
||||
//console.error(error);
|
||||
}
|
||||
}
|
||||
});
|
||||
return count;
|
||||
};
|
||||
|
||||
const totalCommands = loadCommands("../commands");
|
||||
console.log(`Commands => ${totalCommands} commandes préfixées chargées sur le bot\n`);
|
||||
};
|
||||
Reference in New Issue
Block a user