1
0
forked from noxious/server
This commit is contained in:
2024-09-30 23:31:00 +02:00
parent 7b3c4b92a5
commit 4cbd62cbb0
2 changed files with 28 additions and 30 deletions

View File

@ -20,6 +20,8 @@ class CommandManager {
this.rl.on('close', () => {
this.rlClosed = true
})
console.log(process.cwd())
}
public async boot(io: Server) {
@ -61,17 +63,14 @@ class CommandManager {
}
private async loadCommands() {
const baseDir = config.ENV === 'production' ? path.join(__dirname, '..') : process.cwd();
const commandsDir = path.join(baseDir, config.ENV === 'production' ? 'commands' : 'src', 'commands');
const extension = config.ENV === 'production' ? '.js' : '.ts';
const commandsDir = path.join(process.cwd(), 'commands');
commandLogger.info(`Loading commands from: ${commandsDir}`);
try {
const files = await fs.promises.readdir(commandsDir, { withFileTypes: true });
for (const file of files) {
if (!file.isFile() || !file.name.endsWith(extension)) {
if (!file.isFile() || (!file.name.endsWith('.ts') && !file.name.endsWith('.js'))) {
continue;
}