From 8fd68670c9032891823c7427f70e696f96aa51cd Mon Sep 17 00:00:00 2001 From: Dennis Postma Date: Sun, 2 Jun 2024 20:21:31 +0200 Subject: [PATCH] Bug fix for loading commands --- src/app/CommandManager.ts | 18 ++++++------------ src/app/commands/todo.txt | 1 - 2 files changed, 6 insertions(+), 13 deletions(-) delete mode 100644 src/app/commands/todo.txt diff --git a/src/app/CommandManager.ts b/src/app/CommandManager.ts index adc1ded..6925fd4 100644 --- a/src/app/CommandManager.ts +++ b/src/app/CommandManager.ts @@ -14,13 +14,15 @@ class CommandManager { input: process.stdin, output: process.stdout }); - - this.loadCommands(); } public async boot(io: Server) { + // Start the command manager this.io = io as Server; + await this.loadCommands(); console.log('[✅] Command manager loaded'); + + // Start the prompt await this.startPrompt(); } @@ -57,17 +59,9 @@ class CommandManager { for (const file of files) { const ext = path.extname(file); const commandName = path.basename(file, ext); - let commandPath = path.join(commandsDir, file); - - console.log(commandPath); - - if (os.platform() === 'win32') { - commandPath = path.join(commandsDir, file).replace(/\\/g, '/'); - } - - console.log(commandPath); - + const commandPath = path.join(commandsDir, file); const module = await import(commandPath); + this.registerCommand(commandName, module.default); } } catch (error: any) { diff --git a/src/app/commands/todo.txt b/src/app/commands/todo.txt deleted file mode 100644 index 128a830..0000000 --- a/src/app/commands/todo.txt +++ /dev/null @@ -1 +0,0 @@ -In this folder will come commands that can be used in the server console \ No newline at end of file