discordjs/rest

how to fetch all guilds at once? (its returning only 200)
export async function getBotGuildsService() {
const now = Date.now();

// Check if we need to refresh the cache
if (now - guildsCache.lastFetchTime > CACHE_TTL) {
try {
await rest.get(Routes.userGuilds()).then(response=> {
guildsCache.data = response as PartialGuild[]
});

guildsCache.lastFetchTime = now;
} catch (error) {
console.error('Error fetching guilds:', error);
throw error;
}
}

return guildsCache.data;
}
export async function getBotGuildsService() {
const now = Date.now();

// Check if we need to refresh the cache
if (now - guildsCache.lastFetchTime > CACHE_TTL) {
try {
await rest.get(Routes.userGuilds()).then(response=> {
guildsCache.data = response as PartialGuild[]
});

guildsCache.lastFetchTime = now;
} catch (error) {
console.error('Error fetching guilds:', error);
throw error;
}
}

return guildsCache.data;
}
3 Replies
d.js toolkit
d.js toolkit3w ago
- 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!
Shahar
ShaharOP3w ago
I'm building a dashboard that needs to display all the guilds where the bot is present staff I see, maybe its better to understand how to check which of the user's guilds have the bot which end point is that? Once I have the user's guilds, how can I check if my bot is a member of those guilds?
monbrey
monbrey3w ago
From a UX perspective, seeing over 200 things at once is pretty useless to a user too Paginate the UI in the same way the API is paginated is also an option

Did you find this page helpful?