Server Insight Question

is there any way to get information from server's insight like how many users are connected from phone or pc?
3 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
LEON
LEON2y ago
you need these intentions:
const { Client, Intents } = require('discord.js');

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

const client = new Client({
intents:[
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MEMBERS,
Intents.FLAGS.GUILD_PRESENCES,
],
});
to count users you need to use this code
const members = client.guilds.cache.get('1076594113002086400').members.cache;
const presences = members.map(member => Object.keys(member.presence?.clientStatus || []));
const desktopCount = presences.filter(el => el.includes('desktop')).length;
const mobileCount = presences.filter(el => el.includes('mobile')).length;

console.log(`Phone: ${mobileCount}\nPC: ${desktopCount}`)
const members = client.guilds.cache.get('1076594113002086400').members.cache;
const presences = members.map(member => Object.keys(member.presence?.clientStatus || []));
const desktopCount = presences.filter(el => el.includes('desktop')).length;
const mobileCount = presences.filter(el => el.includes('mobile')).length;

console.log(`Phone: ${mobileCount}\nPC: ${desktopCount}`)
LEON
LEON2y ago
also in the bot settings you need to enable this
Want results from more Discord servers?
Add your server