#Why user is null?
1 messages · Page 1 of 1 (latest)
Can you share more of the code? That one statement isn't helpful to go off
string messageToSend = String.Empty;
ulong guildId = (ulong) command.GuildId;
foreach (var user in userDb)
{
var guildUser = _client.GetGuild(guildId).GetUser(user.Id);
if (guildUser != null)
messageToSend += $"*{guildUser}* {RankGrade.StringCreator(user.RankGrade)}\n";
}
await command.RespondAsync(messageToSend);
Only thing I can think is that you have null entries in userDb
No, there are no null entries.
Perhaps this is due to the way Discord works, if the user writes a command or participates in correspondence, then the bot receives user instance.
You can see on a screenshot that bot doesn't get null after I get user info.