guild members data not refreshing on .fetch()

async function fetchMember(memberID) {
const guild = await client.guilds.fetch(guildID);
const guildFetched = await guild.fetch();
const member = await guildFetched.members.fetch(memberID);
return member;
}
async function fetchMember(memberID) {
const guild = await client.guilds.fetch(guildID);
const guildFetched = await guild.fetch();
const member = await guildFetched.members.fetch(memberID);
return member;
}
the data of member never changing
5 Replies
d.js toolkit
d.js toolkit12mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
KAVI
KAVI12mo ago
A better approach would be to use fetch once in the code and then use the cache for other purposes The cache will be automatically updated via the gateway so no need to call fetch again to update it And the cache is much faster than fetching as well. Saving precious process time for responding faster
V2
V212mo ago
but no data has changed either way
KAVI
KAVI12mo ago
It should work if you've implemented it the right way with the right intents And in that code it should be <Guild>.members.fetch() Fetching everything just to fetch a member is not efficient I have a fetch code that runs once in the ready event that readies the cache And after that everywhere it uses the cache and it works without any issues Even member counters when members are added and removed
V2
V212mo ago
my problem was with the intents. thank you ❤️