Caching missing/undefined guild members #7963
-
Hello! We appear to be hitting rate limits when attempting to fetch members that aren't part of the guild because discord.js understandably doesn't cache missing members. Whilst we can implement this caching ourselves, we wanted to check if there's an existing solution that discord.js provides to essentially cache missing members for a predefined amount of time (e.g. 30 seconds)? To clarify, the current discord.js functionality is the following: // Makes API call and returns undefined
let missingMember = await guild.members.fetch(missingId);
// Makes another API call
missingMember = await guild.members.fetch(missingId); However, we're wanting to prevent unnecessary API calls by caching the undefined member for a brief period of time. The end result would look something like the following: // Makes API call and returns undefined
let missingMember = await guild.members.fetch(missingId);
// Does not make another API call because we already know this member is missing
missingMember = await guild.members.fetch(missingId); As previously mentioned, we can implement this ourselves however I'm sure others must've also encountered issues. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
I'm very confused!
How... how can you even fetch members that aren't part of the guild? Discord will reject your API request! Also, what is a 'missing member'? I'm not sure what this terminology means. All of your code block samples should never return As for the caching part, discord.js doesn't have a default limit on caching guild members. If you are losing guild members, that means you are sweeping them out of the cache (and that means you know you are doing it). |
Beta Was this translation helpful? Give feedback.
-
We've since implemented on our side to prevent unnecessary API calls. |
Beta Was this translation helpful? Give feedback.
We've since implemented on our side to prevent unnecessary API calls.