From 25251d50126dc181301fb470a69650a5b38a87a0 Mon Sep 17 00:00:00 2001 From: Dennis Postma Date: Sun, 2 Jun 2024 20:24:05 +0200 Subject: [PATCH] Improved command loading a bit for better debugging --- src/app/CommandManager.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/app/CommandManager.ts b/src/app/CommandManager.ts index 6925fd4..140a9b8 100644 --- a/src/app/CommandManager.ts +++ b/src/app/CommandManager.ts @@ -53,19 +53,19 @@ class CommandManager { private async loadCommands() { const commandsDir = path.resolve(__dirname, 'commands'); + const files: string[] = await fs.promises.readdir(commandsDir); - try { - 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 commandName = path.basename(file, ext); const commandPath = path.join(commandsDir, file); const module = await import(commandPath); this.registerCommand(commandName, module.default); + } catch (error: any) { + console.error('[❌] Failed to load file:', file, error); } - } catch (error: any) { - console.error('[❌] Failed to load command files:', error.message); } }