How can I update variable data in an embed message?
I have an embedded message in which I use other variables from config.json for outputting the right data at the right time. But the problem is that when I change the config.json and output the embed message again - it is not updated. I have to restart the bot, and that's not what I need.
9 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!
- ✅
Marked as resolved by staffyou have to reinitialize your config variable, not djs related
a config.json isnt meant to be dynamic
you should use databases for that
How will the database help solve the problem? My config.json can be said to be a local database that contains country data that will change as the bot is used. All I need is that when I output information about the country, the current information is displayed, which is recorded in config.json. The usual query works for me, but the embed message is not updated.
because a database doesnt require you to initialize your whole config variable
and i also think its cached so you would have to reload it
I'll try to make a database one of these days. About caching - what do you mean?
when you require() a file, it'll be cached, so you would have to delete the require cache to import it again
Got it, thanks for the help!
@treble/luna I tried deleting the cache as you said. The data is now updated. Thank you again for solving the problem!