I have created a simple Discord bot in Node.js. I've enabled GUILD_MEMBERS and GUILD_PRESENCES intents, yet when I try and fetch all members, it is only returning online members.
import { Client } from "discord.js";
const client = new Client({intents: ["GUILDS","GUILD_MESSAGES","GUILD_MEMBERS","GUILD_MESSAGE_REACTIONS", "GUILD_PRESENCES"]});
const guildId = '<guild_id>';
client.on("ready", async () => {
console.log(`logged in as ${client.user.tag}`);
const guild = await client.guilds.fetch(guildId);
const members = await guild.members.fetch();
members.forEach(member => console.log(member.displayName);
});
Output, with my main account online and my alt offline:
logged in as bot1#tagg
mainaccount
bot1
Output, with my main account online and my alt online:
logged in as bot1#tagg
mainaccount
altaccount
bot1
And when I change the log to console.log(member.presence.status), the output is
logged in as bot1#tagg
online
online
online
As you can see, I am fetching all members and logging their display names. I currently have my main account, my alt account and the bot account in the server, but it only logs the names of the members that are currently online. Why is this, and how can I fix it?