1
0
forked from noxious/server

Bug fix for loading commands

This commit is contained in:
Dennis Postma 2024-06-02 20:21:31 +02:00
parent ee18a28006
commit 8fd68670c9
2 changed files with 6 additions and 13 deletions

View File

@ -14,13 +14,15 @@ class CommandManager {
input: process.stdin, input: process.stdin,
output: process.stdout output: process.stdout
}); });
this.loadCommands();
} }
public async boot(io: Server) { public async boot(io: Server) {
// Start the command manager
this.io = io as Server; this.io = io as Server;
await this.loadCommands();
console.log('[✅] Command manager loaded'); console.log('[✅] Command manager loaded');
// Start the prompt
await this.startPrompt(); await this.startPrompt();
} }
@ -57,17 +59,9 @@ class CommandManager {
for (const file of files) { for (const file of files) {
const ext = path.extname(file); const ext = path.extname(file);
const commandName = path.basename(file, ext); const commandName = path.basename(file, ext);
let commandPath = path.join(commandsDir, file); const commandPath = path.join(commandsDir, file);
console.log(commandPath);
if (os.platform() === 'win32') {
commandPath = path.join(commandsDir, file).replace(/\\/g, '/');
}
console.log(commandPath);
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) {

View File

@ -1 +0,0 @@
In this folder will come commands that can be used in the server console