How to get guild member list with Discord4J?

833 Views Asked by At

I'm using Discord4J to access messages or Discord channels. It's working perfectly.

I need to get the member list of the guild to know who is online/offline. I thought with guild.getMembers() I will have this information, but I don't know why, I have only 1 member returned and the status is offline when actually, it's online.

If i use guild.getMemberCount(), I have 10 members.

Why with:

final List<Member> discordMembers = guild.getMembers().collectList().block(TIMEOUT);

I have only 1 member ?

Where is my mistake ?

Update : my Discord4J version is 3.1.5

1

There are 1 best solutions below

0
stefv On

I forgot to turn on the switches "Presence intent" and "Server Members Intent" in the bot configuration page (section Privileged Gateway Intents) of the Discord developers portal.

Now it's working perfectly.