Not getting presence events for server owner

I'm listening for all Events.PresenceUpdate events and seeing them come through for all members of my Discord, other than me, the server/guild owner. Is there something special I need to do permissions wise to allow the bot to get presence updates for my user as well?
11 Replies
d.js toolkit
d.js toolkit2y 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.
TheLegendTubaGuy
TheLegendTubaGuyOP2y ago
14.11.0 node 16.16.0 There's no error as the bot does not receive the presence updates for my user at all.
Azure
Azure2y ago
Have you enabled the Presence Intent under the Privileged Gateway Intents section of the bot settings and added the GuildPresences to the list of intents while initializing your client?
d.js docs
d.js docs2y ago
property (static) IntentsBitField.Flags Numeric WebSocket intents
TheLegendTubaGuy
TheLegendTubaGuyOP2y ago
Yes, to both. And like I said, I get presence updates for seemingly everyone else in the guild. I'm grabbing all of the privileged intents on client instantiation:
const client = new Client({
intents: [Object.keys(GatewayIntentBits)],
});
const client = new Client({
intents: [Object.keys(GatewayIntentBits)],
});
Azure
Azure2y ago
You have any partials?
TheLegendTubaGuy
TheLegendTubaGuyOP2y ago
I do not
Azure
Azure2y ago
I was trying to replicate it, with this code snippet:
const Discord = require('discord.js')
const client = new Discord.Client({ intents: ['GuildMembers', 'GuildPresences', 'Guilds'] })

client.on('ready', async () => { const playground = await client.guilds.fetch('111820271039 9926404') const me = await playground.members.fetch(playground.ownerId) setInterval(async () => {
console.log(me.presence.activities.map(activity => `${activity.applicationId} - ${activity.name}`))
})
const Discord = require('discord.js')
const client = new Discord.Client({ intents: ['GuildMembers', 'GuildPresences', 'Guilds'] })

client.on('ready', async () => { const playground = await client.guilds.fetch('111820271039 9926404') const me = await playground.members.fetch(playground.ownerId) setInterval(async () => {
console.log(me.presence.activities.map(activity => `${activity.applicationId} - ${activity.name}`))
})
But it error'd because it couldn't read the activities of the presence. I added a partial named GuildMember to the partials array of my client initialization call, so it changed to this:
const client = new Discord.Client({ intents: ['GuildMembers', 'GuildPresences', 'Guilds'], partials: [Discord.Partials.GuildMember] })
const client = new Discord.Client({ intents: ['GuildMembers', 'GuildPresences', 'Guilds'], partials: [Discord.Partials.GuildMember] })
And it worked. How about giving it a try? (Sorry about the image or bad code formatting, I am away from my desk so I had to open up termux)
TheLegendTubaGuy
TheLegendTubaGuyOP2y ago
But I can read the activities of presence for the events that I do get. I just literally never get the event for my user.
[12:37:37.101] DEBUG (35419): Got a presence update for xxx that wasn't streaming
[12:37:39.190] DEBUG (35419): Got a presence update for xxx that wasn't streaming
[12:37:45.680] DEBUG (35419): Got a presence update for xxx that wasn't streaming
[12:37:37.101] DEBUG (35419): Got a presence update for xxx that wasn't streaming
[12:37:39.190] DEBUG (35419): Got a presence update for xxx that wasn't streaming
[12:37:45.680] DEBUG (35419): Got a presence update for xxx that wasn't streaming
I'm checking for "Twitch" activity like this:
const streamingActivity = newPresence.activities.find((activity) => activity.type === 1);
const twitchActivity = newPresence.activities.find((activity) => activity.name === 'Twitch');
const streamingActivity = newPresence.activities.find((activity) => activity.type === 1);
const twitchActivity = newPresence.activities.find((activity) => activity.name === 'Twitch');
But again, that's not my issue. My issue is I never see the presence update events for my user.
Azure
Azure2y ago
This went out of my knowledge scope. Sorry about not being able to help you.
TheLegendTubaGuy
TheLegendTubaGuyOP2y ago
okay I'm pretty sure. If I do this, I never see my presence updates:
const { EmbedBuilder, Events } = require('discord.js');
const dayjs = require('dayjs');
const logger = require('../logger');
const {
ANNOUNCE_CHANNEL_ID,
ANNOUNCE_IMAGE_URL,
ANNOUNCE_MESSAGE,
ANNOUNCE_NOTIFY_ROLE_ID,
ANNOUNCE_THUMB_URL,
ANNOUNCE_USER_ID,
} = process.env;

let lastAnnounceSent = dayjs('2020-01-01');

module.exports = {
name: Events.PresenceUpdate,
once: false,
async execute(oldPresence, newPresence) {
const userId = newPresence.userId;
const guild = newPresence.guild;
const liveRole = guild.roles.cache.find((role) => role.name === 'Live Now');
const memberManager = guild.members;
console.log(newPresence);
},
};
const { EmbedBuilder, Events } = require('discord.js');
const dayjs = require('dayjs');
const logger = require('../logger');
const {
ANNOUNCE_CHANNEL_ID,
ANNOUNCE_IMAGE_URL,
ANNOUNCE_MESSAGE,
ANNOUNCE_NOTIFY_ROLE_ID,
ANNOUNCE_THUMB_URL,
ANNOUNCE_USER_ID,
} = process.env;

let lastAnnounceSent = dayjs('2020-01-01');

module.exports = {
name: Events.PresenceUpdate,
once: false,
async execute(oldPresence, newPresence) {
const userId = newPresence.userId;
const guild = newPresence.guild;
const liveRole = guild.roles.cache.find((role) => role.name === 'Live Now');
const memberManager = guild.members;
console.log(newPresence);
},
};
Oh... I bet hiding my activity status does that
Want results from more Discord servers?
Add your server