Null members usernames when requesting all members from a guild
Created by: FenikkusuKoneko
Summary
The usernames of the members in a guild are null if you request them in chunks and have the Presences Intent disabled as Discord doesn't sent any member on bot startup and the all members request will be used more frequently.
Details
The new Intents are coming and they will be mandatory.
If Presences Intent is disabled then Discord will not send any member when the bot starts up. Maybe they will do this in the future.
So for now requesting all members in chunks in a guild will be more necessary.
When you request all members from a guild, their username is null, only their nickname and other member related fields are populated but not the user fields.
I was following the code in the OnGuildMembersChunkEventAsync
in DiscordClient.cs
:
https://github.com/DSharpPlus/DSharpPlus/blob/master/DSharpPlus/DiscordClient.cs#L2059-L2127
Then I checked, as curiosity, the code from the DiscordMember.cs's constructor
:
https://github.com/DSharpPlus/DSharpPlus/blob/master/DSharpPlus/Entities/DiscordMember.cs#L33-L44
and saw that the fields about the user are not stored.
Steps to reproduce
- Enable the unprivileged intents and the members intent, no presences intent.
- When the bot is ready, request the members from a guild.
- Get the members from that guild, get a member and then get its username, or debug a member from that list of members. You will see that the username is null, the nickname is set if that user has a nickname in the guild.