cache question
Hey, my bot is in a server with 200k members and I need to fetch members every 5mins, currently doing members.fetch(), but can I just use guild.members.cache
How accurate cache is for that
26 Replies
You should only need to fetch members once, and then the cache will update as new members join/leave/update
why do you fetch members every 5min anyway
Cache can hold 200k members?
I mean it’s not every 5mins it happens on button interaction but yeah its either that or using cache
So im asking if using cache is safe here
The only limit is your memory. d.js does not limit any cache except messages unless you specify otherwise
as mark said, but you can also use your own cache, and store only the data you need
I need every member of server
fetch() is expensive and rate-limited
I never got rate limited somehow
I only had errors like “Members didn’t arrive in time”
2-3 times a day
that's the thing, members.cache will not reflect the true number of members unless you've fetched
what exactly do you need from each of the members?
Username, nickname, id, displayname
Everything basically
On button click a modal is opened that asks for query input
When you submit modal it will find a member with that query
So on every modal submit I fetch members and do members.find
thats simple, just check the cache first to find that query. If not found, fetch with THAT query
Wdym fetch with that query
Do you mean members.fetch({ query)}
Or

Is it possible to use UserSelectMenu in dms?
That might be even easier and better
it does not work
Rip
that's the best way for it; check the cache first, if not found, fetch
if you send the required intents and keep the bot online it will update the cache based on the received guild member add and delete events
that depends on both how you configured your cache as well as your available memory and the memory footprint you want or have to achieve
I didn’t configured cache
Its default
i've done a server with north of 2 million
And also I gave bot unlimited memory which is like 16gb
what's much less feasible is fetching 200 people with the paginated endpoint every few minutes
just do this
you don't need every member
does that actually work on all name variants now?
iirc it didn't when globals were introduced (at least for a while)
is hydra the username here? Or what exactly is “query”? Because I think you have to pass IDs here?
ooo. so hydra is the username
:thumbsup: