Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

205
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!