Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

209
Vistas
Finding a certain users status in discord.js

Okay so I am trying to make a discord bot that detects when a certain user is online in my server. But every time I try to get the users presence status it always says "const usersStatus = user.presence.status; TypeError: Cannot read properties of undefined (reading 'status')". How do I get the presence status of a specific user? Here's my code so far

const { Client, Intents } = require('discord.js');
const { token} = require('./config.json');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_PRESENCES] });

const user = client.users.fetch('Users ID');
const usersStatus = user.presence.status;

client.once('ready', () => {
    console.log("should be online");
    console.log(usersStatus);
})

//place at end of file
client.login(token);
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

In Discord, offline members don't have any presence, so the presence is null, hence you get the error.

So if presence is null, either the User defined isn't a user or they are offline.

Secondly, you will need to resolve the promise by adding await

Usually, I would do this to get to know their status.

let user = await client.users.fetch("ID")
console.log(`${user.tag}'s presence status: ${user.presence?.status ?? "offline"}`)

This will log for example: Ashish#0540's presence status: dnd if the person is on do not disturb, or Ashish#0540's presence status: offline

about 4 years ago · Juan Pablo Isaza Denunciar

0

client.users.fetch returns a Promise. You will need to await it and get the presence from there

(async () => { //await needs async
const user = await client.users.fetch('Users ID');
const usersStatus = user.presence.status
})()

Additionally, you won't get any users if the client is not ready. You should make sure this is in your ready event so the client fetches the user properly.

In discord.js v13 Users don't have presences. This is only on GuildMembers now. I believe this is for security reasons - like bots can only DM members they are in a guild with. You can get any guild that this user is in, then get the member from there where you will then get their status

const member = await guild.members.fetch('Users ID'); //remember you still need async
const membersStatus = member.presence.status
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda