sapphiredev/framework

request: HMR

Suyashtnt opened this issue · 0 comments

Is there an existing issue or pull request for this?

  • I have searched the existing issues and pull requests

Feature description

Right now most discord bot frameworks require you to do a full restart to see your new bot changes. This can be slow and annoying when trying to iterate quickly.

HMR is a feature in java/kotlin, and you can use it with things like JDA to update your bot code while its still running.

This is technically possible in sapphire(https://www.sapphirejs.dev/docs/Documentation/api-pieces/classes/Piece#reload), but there is no easy way to actually use this right now, and thats where this feature equest comes in.

Desired solution

There are 2 possible solutions:

  • A command in the CLI
  • A plugin

The CLI command could be something like sapphire dev, which starts your bot and watches for changes, when a change is detected, it will recompile your project and reload the specific commands/listeners/pieces changed, based on what files have been updated.

The plugin will work similarly, you add the plugin and any file change will trigger a recompile and HMR, but will have direct code access so it should be a lot easier to implement

Alternatives considered

the closest thing to a hot reload is ctrl+c,up arrow, and enter

Additional context

Discord message that started this: https://discord.com/channels/737141877803057244/737142774738190377/927948497729257522