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

277
Views
Discord JS V13 member.presence.status (Cannot read properties of null (reading 'status'))
const { GuildMember, MessageEmbed } = require("discord.js");

module.exports = {
    name: "guildMemberAdd",
    /**
     * @param {GuildMember} member
     */
    execute(member){
        const totalUsers = member.guild.channels.cache.get(process.env.totalUsers)
        const onlineUsers = member.guild.channels.cache.get(process.env.onlineUsers)

        var userCount = member.guild.memberCount
        var onlineCount = member.guild.members.cache.filter(m => m.presence.status === 'online').size

        totalUsers.setName("Total Users: " + userCount)
          
        onlineUsers.setName("Online Users: " + onlineCount)  

        member.guild.channels.cache.get(process.env.WELCOME_MESSAGE_CHANNEL_ID).send({ 
            embeds: [
                new MessageEmbed()
                .setTitle("Welcome! :smiley:")
                .setDescription(`${member.toString()} has joined the server!\n
                                Thanks for joining. Head over to <#${process.env.RULE_CHANNEL_ID}> and verify yourself in <#${process.env.VERIFY_CHANNEL_ID}> to get access to all other channels.`)
                .setThumbnail(member.user.displayAvatarURL())
                .setColor("GREEN")
            ]
        }) 
    }
}

In line 13 I get this error. I want to get all online members of the guild and showcase the number in a channel name

TypeError: Cannot read properties of undefined (reading 'status')

but I it should be working like that if I look into the docs

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You firstly need to fetch the members with <Guild>.members.fetch method, refer here.

Example for your case:

await member.guild.members.fetch();
var onlineCount = member.guild.members.cache.filter(m => m.presence.status === 'online').size
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!