Skip to content

Commit

Permalink
fix: UserMentions throwing NullRef
Browse files Browse the repository at this point in the history
  • Loading branch information
SubZero0 committed Nov 26, 2020
1 parent 5213916 commit 5ed01a3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/Discord.Net.WebSocket/Entities/Messages/SocketUserMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,14 @@ internal override void Update(ClientState state, Model model)
for (int i = 0; i < value.Length; i++)
{
var val = value[i];
var guildUser = guild.GetUser(val.Id);
if (guildUser != null)
newMentions.Add(guildUser);
else if (val.Object != null)
newMentions.Add(SocketUnknownUser.Create(Discord, state, val.Object));
if (val.Object != null)
{
var user = Channel.GetUserAsync(val.Object.Id, CacheMode.CacheOnly).GetAwaiter().GetResult() as SocketUser;
if (user != null)
newMentions.Add(user);
else
newMentions.Add(SocketUnknownUser.Create(Discord, state, val.Object));
}
}
_userMentions = newMentions.ToImmutable();
}
Expand Down

0 comments on commit 5ed01a3

Please sign in to comment.