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
chillihero•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
chillihero•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
More Posts
Store a data in Client context ShappireHow can i store a object value in client context shappire Im trying to create a music queue cachedType 'ServerResponse' is not genericHello guys, I just updated the sapphire packages and I am encountering an error with the plugin-apiIs there a Example on how to work with the API Plugin directly in the bot?I want to try out how that is working, is there an example Repository somewhere? Because the Docs arCreating slash command with options and sapphire cli templateHey there. I'm using the bot template from the sapphire cli and now wanted to try and create a slashIs there any utility to check if a member has permission to run a command?Hi! I have a bot that needs to check if a member has permission to run a command and then do somethiSend and Reply from the editable-commands plugin do the same wrong thing.So I tried out both of them and none seems to respond on the interaction. what I want: image 1 whatwhat is this regex supposed to mean?What is the Best approach to developing a bot and reloading the new changes into it?I heard that logging in too many times can lead to rate limits. is there a good solution for this isHow do I create subcommands with different text input fields?Something like the image. The Docs only show how to create basic subcommands. Also in the Readme of Best Approach on separating Commands from their "run" file to a separate FolderFor context, I am super new to discordjs and this framework so apologizes if this question sounds od