Improved command loading a bit for better debugging

This commit is contained in:
Dennis Postma 2024-06-02 20:24:05 +02:00
parent 8fd68670c9
commit 25251d5012

View File

@ -53,19 +53,19 @@ class CommandManager {
private async loadCommands() { private async loadCommands() {
const commandsDir = path.resolve(__dirname, 'commands'); const commandsDir = path.resolve(__dirname, 'commands');
try {
const files: string[] = await fs.promises.readdir(commandsDir); const files: string[] = await fs.promises.readdir(commandsDir);
for (const file of files) { for (const file of files) {
try {
const ext = path.extname(file); const ext = path.extname(file);
const commandName = path.basename(file, ext); const commandName = path.basename(file, ext);
const commandPath = path.join(commandsDir, file); const commandPath = path.join(commandsDir, file);
const module = await import(commandPath); const module = await import(commandPath);
this.registerCommand(commandName, module.default); this.registerCommand(commandName, module.default);
}
} catch (error: any) { } catch (error: any) {
console.error('[❌] Failed to load command files:', error.message); console.error('[❌] Failed to load file:', file, error);
}
} }
} }