fetch users

I'm developing a team system in my Discord bot, where each team can have multiple users. Now I want to create a select menu to remove users who are already in a team. The idea is to fetch these users to dynamically build the menu, but since a team can have many users, I'm pretty sure this will hit the Discord API rate limits. Has anyone faced a similar issue or has suggestions on how to handle this in the best way? I was trying to use interaction.guild.members.fetch by passing an array of users, but this only works for users in the server, which is also a problem.
7 Replies
d.js toolkit
d.js toolkit4w ago
Amgelo
Amgelo4w ago
if you call fetch on a user that's already cached it'll return the cached one, it won't fetch
thiago
thiagoOP4w ago
so, is <Guild>.members.fetch() the best choice?
Amgelo
Amgelo4w ago
but this only works for users in the server
you mentioned this, so my guess is that you want to fetch users, not members it'd be <Client>.users.fetch() instead
thiago
thiagoOP4w ago
lol yeah sorry tysm
Steve
Steve3w ago
what if you want updates information
Amgelo
Amgelo3w ago
bots receive updates of users they share servers with via the userUpdate event so those will already be up to date if it's an arbitrary user then yeah you might want to force the fetch

Did you find this page helpful?