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