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:
Helper functions for making better use of @commandhandler/core
``typescript `
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:
`typescript``
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"],
}),
)