I’m working on a Discord bot dashboard using Node.js and Express. I’ve run into an issue with displaying server information on the /guilds path. Sometimes, not all server information is rendered properly, and the information only displays after refreshing the page with F5. I’ve tried using Promise.All, but the issue persists. I’m wondering if this issue is caused by Discord API limitations or if there’s something else at play. Does anyone have any insights or suggestions?
const user = req.session.user;
const guilds = req.session.guilds;
const botGuilds = [];
if (!user) {
return res.redirect('/auth/discord');
}
await client.guilds.fetch();
const botGuildIds = client.guilds.cache.map((guild) => guild.id);
for (const guild of guilds) {
if (botGuildIds.includes(guild.id)) {
const botGuild = await client.guilds.fetch(guild.id);
botGuilds.push(botGuild);
}
}
res.render('guilds', { user: user, guilds: botGuilds });
});```
I've already tried using try-catch blocks, Promise.All and various console.log statements to arrive at the error somehow.