Sitelet https://web.archive.org/web/20211109044424/https://github.com/DV8FromTheWorld/JDA/discussions/1667
Skip to content

Create a function that puts the number of users in a certain server id or all servers combined of a server bot into a into basically a int required function that gathers the number of users in a server or a total number of servers #1667

Unanswered
MasterScary asked this question in Questions and Help
Create a function that puts the number of users in a certain server id or all servers combined of a server bot into a into basically a int required function that gathers the number of users in a server or a total number of servers #1667
Jun 14, 2021 · 2 answers

just think this may be a cool easy feature

Replies

2 suggested answers

Please ask in the JDA Discord next time, as we could've answered this question fairly easy.

In general, there are more than enough ways to get specific values such as total amount of members or from specific guilds.

Here are two examples I quickly made.

JDA jda = JDABuilder.createDefault("S3cretT0k3n")
    .enableIntents(GatewayIntent.GUILD_MEMBERS) // Those are required to get Guild members
    .setChunkingFilter(ChunkingFilter.ALL)
    .setMemberCachePolicy(MemberCachePolicy.ALL)
    .build();

// get all users in total:
long totalUsers = jda.getUserCache().size();

// get from a specific server
long guildUsers = jda.getGuildById(1234567890L).getMemberCount();

Also, follow the issue template next time please :)

0 replies

no worries we already did 🙃

0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
❓
Questions and Help
Labels
None yet
3 participants
Converted from issue