Is there a problem if I use 'force: true' everytime I want to fetch a user?
So, I'm doing some testings to one of the commands of my bot, before adding it to the rest. My idea is to always try to get the most recent info of a user; in this case, I'm trying to validate if the user has a specific role from a specific guild. The command depends on this to be able to perform certain actions, and this command can be executed from other guilds (that's the idea).
So, the code works really good as it looks. My question is if it's a bad practice to use
force: true
in literally every single of my commands. The API is gonna limit it at some point? If the bot is used very frequently later on, will it be a problem?
Test code:6 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 OPdiscord.js 14.16.3
node 20.14.0
Unknown User•3w ago
Message Not Public
Sign In & Join Server To View
The member's cache is updated if you have
GuildMembers
intentUnknown User•3w ago
Message Not Public
Sign In & Join Server To View
Yeah so my initial approach was to not to apply the force attribute, but I had issues with it. For example:
If the role is added to the user from server X, and the user executes the command from server Y, the user's info is not properly obtained (not updated). What solves the issue is reuse the command on the server X or restart the bot, which is not preferable.
That's why I was using
force: true
. It solves the problem but in the long run I don't want to get issues if the bot gets a lot of traffic.
I will try to add the GuildMembers intent to see if that fixes the problem!
Okey so I removed the force
attribute and added GuildMembers
. It works fine! I was just concerned that later on I would have problems because of the number of requests.
Thank you guys!