#Impossible to reach user.presence.status

13 messages · Page 1 of 1 (latest)

robust grail
#

Hi back,

I encounter again a little issue concerning user's presence status. Within my script, the property seems absent from the retrieved GuildMember, even if the doc mentions this property should exist: https://discord.js.org/#/docs/main/stable/class/GuildMember?scrollTo=presence

I well turned on the "Privileged Gateway Intents" > "Presence Intent" in the "Bot" section of the developer portal application website.
To be sure, I turned off the bot, kicked it from my server, invited it back, and restarted the bot, but it didn't resolve the issue.

const member = await interaction.guild.members.fetch(userId).catch(() => {}); // userId being mine.
console.log(member) // well display all information, but there is no key "presence"
console.log(member.presence.status) // Throw an error: Cannot read properties of null (reading 'status')

Did I miss something?

thick pilotBOT
#

• 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.

vocal goblet
#

do you have the intent in your client constructor?

robust grail
#

I have those ones:

const { Guilds, GuildMembers, GuildMessages, GuildPresences } =
    GatewayIntentBits;
const client = new Client({
    intents: [Guilds, GuildMembers, GuildMessages, GuildPresences]
});
stoic shell
#

offline members don't have a presence btw

robust grail
#

Yet there is an offline status
But anyway, I'm online

stoic shell
robust grail
#

Alright but I was already online when I started the bot, so I should have a presence

#

Okay I tried it again and it works now, I still don't see it in the console.log(member), but if I do a console.log(member.presence) it well returns the Presence object.

#

I literally changed nothing... I don't understand why such bugs happen. I had the same problem yesterday with a slash command that didn't show even if I reloaded the bot. Today it appears...

#

Is there a cache or something I can force to be cleared?

late drum
#

presence is a get property on GuildMember objects so won‘t show up in a console.log of it. And there is a cache or guild presences but I doubt you mean that (because that gets cleared on restarts of your bot anyway)

robust grail
#

Oh okay, good to know