Skip to content

Commit

Permalink
[Fix] Updated global name not being passed to UserUpdated event (#2726
Browse files Browse the repository at this point in the history
)

* fix

* fix another overgisht
  • Loading branch information
Misha-133 authored Aug 10, 2023
1 parent 184a536 commit 9dfd4d7
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal class SocketGlobalUser : SocketUser
public override string Username { get; internal set; }
public override ushort DiscriminatorValue { get; internal set; }
public override string AvatarId { get; internal set; }
public override string GlobalName { get; internal set; }
internal override SocketPresence Presence { get; set; }

public override bool IsWebhook => false;
Expand Down
2 changes: 2 additions & 0 deletions src/Discord.Net.WebSocket/Entities/Users/SocketGroupUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public class SocketGroupUser : SocketUser, IGroupUser
/// <inheritdoc />
public override string AvatarId { get { return GlobalUser.AvatarId; } internal set { GlobalUser.AvatarId = value; } }
/// <inheritdoc />
public override string GlobalName { get { return GlobalUser.GlobalName; } internal set { GlobalUser.GlobalName = value; } }
/// <inheritdoc />
internal override SocketPresence Presence { get { return GlobalUser.Presence; } set { GlobalUser.Presence = value; } }

/// <inheritdoc />
Expand Down
2 changes: 2 additions & 0 deletions src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public class SocketGuildUser : SocketUser, IGuildUser
public override ushort DiscriminatorValue { get { return GlobalUser.DiscriminatorValue; } internal set { GlobalUser.DiscriminatorValue = value; } }
/// <inheritdoc />
public override string AvatarId { get { return GlobalUser.AvatarId; } internal set { GlobalUser.AvatarId = value; } }
/// <inheritdoc />
public override string GlobalName { get { return GlobalUser.GlobalName; } internal set { GlobalUser.GlobalName = value; } }

/// <inheritdoc />
public GuildPermissions GuildPermissions => new GuildPermissions(Permissions.ResolveGuild(Guild, this));
Expand Down
2 changes: 2 additions & 0 deletions src/Discord.Net.WebSocket/Entities/Users/SocketSelfUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public class SocketSelfUser : SocketUser, ISelfUser
/// <inheritdoc />
public override string AvatarId { get { return GlobalUser.AvatarId; } internal set { GlobalUser.AvatarId = value; } }
/// <inheritdoc />
public override string GlobalName { get { return GlobalUser.GlobalName; } internal set { GlobalUser.GlobalName = value; } }
/// <inheritdoc />
internal override SocketPresence Presence { get { return GlobalUser.Presence; } set { GlobalUser.Presence = value; } }
/// <inheritdoc />
public UserProperties Flags { get; internal set; }
Expand Down
7 changes: 7 additions & 0 deletions src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,13 @@ public override string AvatarId
get => GuildUser.AvatarId;
internal set => GuildUser.AvatarId = value;
}

/// <inheritdoc />
public override string GlobalName
{
get => GlobalUser.GlobalName;
internal set => GlobalUser.GlobalName = value;
}
/// <inheritdoc/>
public string DisplayAvatarId => GuildAvatarId ?? AvatarId;

Expand Down
2 changes: 2 additions & 0 deletions src/Discord.Net.WebSocket/Entities/Users/SocketUnknownUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public class SocketUnknownUser : SocketUser
public override ushort DiscriminatorValue { get; internal set; }
/// <inheritdoc />
public override string AvatarId { get; internal set; }
/// <inheritdoc />
public override string GlobalName { get; internal set; }

/// <inheritdoc />
public override bool IsBot { get; internal set; }
Expand Down
4 changes: 2 additions & 2 deletions src/Discord.Net.WebSocket/Entities/Users/SocketUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public abstract class SocketUser : SocketEntity<ulong>, IUser
internal abstract SocketPresence Presence { get; set; }

/// <inheritdoc />
public string GlobalName { get; internal set; }
public abstract string GlobalName { get; internal set; }

/// <inheritdoc />
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
Expand Down Expand Up @@ -93,7 +93,7 @@ internal virtual bool Update(ClientState state, Model model)
PublicFlags = model.PublicFlags.Value;
hasChanges = true;
}
if (model.GlobalName.IsSpecified)
if (model.GlobalName.IsSpecified && model.GlobalName.Value != GlobalName)
{
GlobalName = model.GlobalName.Value;
hasChanges = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public class SocketWebhookUser : SocketUser, IWebhookUser
public override ushort DiscriminatorValue { get; internal set; }
/// <inheritdoc />
public override string AvatarId { get; internal set; }

/// <inheritdoc />
public override string GlobalName { get; internal set; }

/// <inheritdoc />
public override bool IsBot { get; internal set; }
Expand Down

0 comments on commit 9dfd4d7

Please sign in to comment.