Skip to content

Commit

Permalink
[Fix] NRE on thread member creation without a guild user in the paylo…
Browse files Browse the repository at this point in the history
…ad (#3030)

lets hope for the best
  • Loading branch information
Misha-133 authored Nov 23, 2024
1 parent a1e50c4 commit 96a8327
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,14 @@ internal SocketThreadUser AddOrUpdateThreadMember(ThreadMember model, SocketGuil
member.Update(model);
else
{
member = SocketThreadUser.Create(Guild, this, model, guildMember);
member.GlobalUser.AddRef();
member = SocketThreadUser.Create(Guild, this, model, guildMember ?? Guild.GetUser(model.UserId.GetValueOrDefault(0)));
member.GlobalUser?.AddRef();
_members[member.Id] = member;
}
return member;
}

/// <inheritdoc />
/// <inheritdoc cref="SocketGuildChannel.GetUser"/>
public new SocketThreadUser GetUser(ulong id)
{
var user = Users.FirstOrDefault(x => x.Id == id);
Expand Down
4 changes: 2 additions & 2 deletions src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,9 @@ internal void Update(Model model)
public override string GetDisplayAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128)
=> GuildUser.GetGuildAvatarUrl() ?? base.GetDisplayAvatarUrl(format, size);

internal override SocketGlobalUser GlobalUser { get => GuildUser.GlobalUser; set => GuildUser.GlobalUser = value; }
internal override SocketGlobalUser GlobalUser { get => GuildUser?.GlobalUser; set => GuildUser.GlobalUser = value; }

internal override SocketPresence Presence { get => GuildUser.Presence; set => GuildUser.Presence = value; }
internal override SocketPresence Presence { get => GuildUser?.Presence; set => GuildUser.Presence = value; }

/// <summary>
/// Gets the guild user of this thread user.
Expand Down

0 comments on commit 96a8327

Please sign in to comment.