incorrect presence display

I have 3 users on the server with the status "idle", but for some reason it shows that 1 with the status "online", and 2 with the status "idle" Code:
import { SlashCommandBuilder } from 'discord.js';

export const data = new SlashCommandBuilder()
.setName('stats')
.setDescription('Статистика пользователей.');

export async function execute(interaction, client) {
await interaction.deferReply({ ephemeral: true });

const guild = await client.guilds.fetch(interaction.guildId);

const onlineUsers = Array.from(guild.members.cache.filter(m => m.presence.status === 'online')).length;
const idleUsers = Array.from(guild.members.cache.filter(m => m.presence.status === 'idle')).length;
const offlineUsers = Array.from(guild.members.cache.filter(m => m.presence.status === 'offline')).length;
const dndUsers = Array.from(guild.members.cache.filter(m => m.presence.status === 'dnd')).length;

await interaction.editReply({
content: `Онлайн: ${onlineUsers}\nОтошли: ${idleUsers}\nНе беспокоить: ${dndUsers}\nОффлайн: ${offlineUsers}`,
ephemeral: true
});
}
import { SlashCommandBuilder } from 'discord.js';

export const data = new SlashCommandBuilder()
.setName('stats')
.setDescription('Статистика пользователей.');

export async function execute(interaction, client) {
await interaction.deferReply({ ephemeral: true });

const guild = await client.guilds.fetch(interaction.guildId);

const onlineUsers = Array.from(guild.members.cache.filter(m => m.presence.status === 'online')).length;
const idleUsers = Array.from(guild.members.cache.filter(m => m.presence.status === 'idle')).length;
const offlineUsers = Array.from(guild.members.cache.filter(m => m.presence.status === 'offline')).length;
const dndUsers = Array.from(guild.members.cache.filter(m => m.presence.status === 'dnd')).length;

await interaction.editReply({
content: `Онлайн: ${onlineUsers}\nОтошли: ${idleUsers}\nНе беспокоить: ${dndUsers}\nОффлайн: ${offlineUsers}`,
ephemeral: true
});
}
8 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.
Kinect3000
Kinect30002y ago
Do you have the guild presences intent enabled in the code?
vlad vollar
vlad vollarOP2y ago
yes GatewayIntentBits.GuildPresences if not intent, all users "offline"
Kinect3000
Kinect30002y ago
Can you check who it thinks is online?
vlad vollar
vlad vollarOP2y ago
Bot, that run the code
Kinect3000
Kinect30002y ago
Is the bot in other guilds?
vlad vollar
vlad vollarOP2y ago
Yes up "onClientReady.js" is connected to "bot.js"
client.on(Events.ClientReady, () => {
client.user?.setPresence({
status: 'idle',
activities: [{name: '/help'}],
})
})
client.on(Events.ClientReady, () => {
client.user?.setPresence({
status: 'idle',
activities: [{name: '/help'}],
})
})
What does it have to do with it if a bot with exactly the same code is displayed as "idle"? Can you clarify how exactly to do it?
d.js docs
d.js docs2y ago
interface ClientOptions Options for a client.
Want results from more Discord servers?
Add your server