@commandhandler/helpers
v1.0.0
Published
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:
Downloads
2
Maintainers
Readme
@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"],
}),
)