HMR not Working correctly

I am using the @sapphire/plugin-hmr Plugin to reload my bot on code changes without relogging to discord. When I change the text in an embed for example and hmr reloads my changes, they are displayed correctly in discord with the new text. If you change console logs, add container.logger.info(xyz) or edit helper files, the changes there are not reflected correctly with the latest changes. If I want to see the changes I have to stop the dev process and restart the bot completely. Is this wanted behavior or am I doing something wrong?
Solution:
This is expected behavior. @sapphire/plugin-hmr only handles "piece" files (commands, listeners, preconditions, etc)
Jump to solution
6 Replies
Np 🌸
Np 🌸•2y ago
Probably use the watch script like tsc --watch yourfile.js
chillihero
chilliheroOP•2y ago
I run npm run dev. npm run dev runs run-p watch start watch = tsc -w start = node dist/index.js
Solution
Lioness100
Lioness100•2y ago
This is expected behavior. @sapphire/plugin-hmr only handles "piece" files (commands, listeners, preconditions, etc)
Lioness100
Lioness100•2y ago
What you might be able to do is change and save a helper file, and then change and save a command file that uses it. This forces the command to reload, which would reimport the helper file with the new changes I'm not sure if that works but it would be worth a try
chillihero
chilliheroOP•2y ago
tried and its not working :( an option to reload on all file changes would be dope tbh
Favna
Favna•2y ago
that won't really be added because there is no good way to reload files in a running process anyway in CJS there is require cache, and in ESM you can add query params to imports but both are very so/so You can add it to your own bot or make your own plugin, but we won't be adding it
Want results from more Discord servers?
Add your server