#Server Insight Question

4 messages · Page 1 of 1 (latest)

upper olive
#

is there any way to get information from server's insight like how many users are connected from phone or pc?

honest patrol
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

thick trellis
#

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,
    ],
});

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}`)
#

also in the bot settings you need to enable this