@commandhandler/helpers
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@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"],
    }),
)

Package Sidebar

Install

npm i @commandhandler/helpers

Weekly Downloads

2

Version

1.0.0

License

none

Unpacked Size

18.2 kB

Total Files

8

Last publish

Collaborators

  • radioactive-publish-bot