1.0.0 • Published 2 years ago

@commandhandler/helpers v1.0.0

Weekly downloads
-
License
-
Repository
gitlab
Last release
2 years ago

@commandhandler/helpers

Helper functions for making better use of @commandhandler/core

getCommandsFromDir

Fetches javascript files from a specified directory and creates an array from the commands exported by them. Example:

await getCommandsFromDir(path.join(__dirname, "commands"), logManager, {
    exportLocation: CommandExportLocations.DEFAULT,
    exclude: ["*.d.ts", "*.map", "*.component.ts", "*.component.js"],
}),

This example imports commands exported by export default.

Use like:

const commandHandler = new CommandHandler()
commandHandler.addService(/** your service implementation, eg. new DiscordJsImplementation(client) **/)
commandHandler.addCommand(
    await getCommandsFromDir(path.join(__dirname, "commands"), logManager, {
        exportLocation: CommandExportLocations.DEFAULT,
        exclude: ["*.d.ts", "*.map", "*.component.ts", "*.component.js"],
    }),
)