1
0
forked from noxious/server
This commit is contained in:
2024-12-28 21:26:31 +01:00
parent 4f1b9cf024
commit 5c94584cb2
4 changed files with 12 additions and 15 deletions

View File

@ -1,5 +1,6 @@
import * as fs from 'fs'
import * as path from 'path'
import Logger, { LoggerType } from '#application/logger'
import { getAppPath } from '#application/storage'
import { Command } from '#application/types'
@ -18,11 +19,7 @@ export class CommandRegistry {
try {
const files = await fs.promises.readdir(directory, { withFileTypes: true })
await Promise.all(
files
.filter(file => this.isValidCommandFile(file))
.map(file => this.loadCommandFile(file))
)
await Promise.all(files.filter((file) => this.isValidCommandFile(file)).map((file) => this.loadCommandFile(file)))
} catch (error) {
this.logger.error(`Failed to read commands directory: ${error instanceof Error ? error.message : String(error)}`)
}
@ -56,4 +53,4 @@ export class CommandRegistry {
this.commands.set(name, CommandClass)
this.logger.info(`Registered command: ${name}`)
}
}
}