Snazzah / slash-create

🗡️ Creator and handler for Discord's slash commands
https://slash-create.js.org
MIT License
348 stars 47 forks source link

Use import() in `SlashCreator#registerCommandsIn()` #445

Open Snazzah opened 1 year ago

Snazzah commented 1 year ago

This mainly requires making the function async, and should also make directory listing also async. While this is gonna be a breaking change for the method, should probably also add a filter function to allow for manual file filtering instead of having a custom extensions array option.

axieum commented 1 year ago

+1, as this will allow consumers to use this in pure ESM projects. For now, I believe the only way is to import and then register each command class manually via the SlashCreator#registerCommand() or SlashCreator#registerCommands().

Snazzah commented 1 year ago

Wasn't exactly able to get this done for v6, but SlashCreator#registerCommandsIn is async, so this could be done in a minor version release. A hurdle was making the TypeScript config work well with both CJS and ESM environments without making the package ESM.