G
G
gavr062020-08-14 20:39:42
Node.js
gavr06, 2020-08-14 20:39:42

How to make a command to count users on the server?

Hello, I am making my discord bot in JavaScript programming language.
I want to make a membercount command to count people on the server, please help!
You can give the necessary arguments (by type member.guild, etc.), but, preferably, complete code.
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander, 2020-08-14
@gavr06

use iterate forEach:

const list = bot.guilds.cache.get("id_гильдии"); 

list.members.forEach(member => message.channel.send(member.user.username));

A
AlmondPark33609, 2021-10-11
@AlmondPark33609

To have the bot send all users with one message, use:

let list = []
let guild = bot.guilds.cache.get('id_гильдии')
guild.members.forEach(m => {
     list.push(m.nickname)
})
message.channel.send(list.join(', '))

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question