I just want to get the count value alone without having to convolute with a loop. I believe this to be extremely simple, but all my usual approaches are giving me promise rejections from the library.
// Get our server
const guild = bot.guilds.get('388093207575134208');
// Get our stats channels
const totalUsers = bot.channels.get('470358845751951361');
const onlineUsers = bot.channels.get('470366354222874665');
const codeMonkeys = bot.channels.get('470358906225295391');
var userCount = guild.memberCount;
var onlineCount = guild.members.filter(m => m.presence.status === 'online');
Getting the members in that presence is pretty easy, but I can't seem to just get the length
of the returned collection.
I just want to get the count value alone without having to convolute with a loop. I believe this to be extremely simple, but all my usual approaches are giving me promise rejections from the library.
// Get our server
const guild = bot.guilds.get('388093207575134208');
// Get our stats channels
const totalUsers = bot.channels.get('470358845751951361');
const onlineUsers = bot.channels.get('470366354222874665');
const codeMonkeys = bot.channels.get('470358906225295391');
var userCount = guild.memberCount;
var onlineCount = guild.members.filter(m => m.presence.status === 'online');
Getting the members in that presence is pretty easy, but I can't seem to just get the length
of the returned collection.
1 Answer
Reset to default 1Using size()
I was able to get the size of the collection. My misconception was that I was treating a collection
like an array
by using Length
.
// Get our server
const guild = bot.guilds.get('388093207575134208');
// Get our stats channels
const totalUsers = bot.channels.get('470358845751951361');
const onlineUsers = bot.channels.get('470366354222874665');
const codeMonkeys = bot.channels.get('470358906225295391');
var userCount = guild.memberCount;
var onlineCount = guild.members.filter(m => m.presence.status === 'online').size