Skip to content

Commit

Permalink
Add DisplayName property to IGuildUser. (#2107)
Browse files Browse the repository at this point in the history
  • Loading branch information
csmir authored Feb 16, 2022
1 parent 169d54f commit abfba3c
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/Discord.Net.Core/Entities/Users/IGuildUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ public interface IGuildUser : IUser, IVoiceState
/// </returns>
DateTimeOffset? JoinedAt { get; }
/// <summary>
/// Gets the displayed name for this user.
/// </summary>
/// <returns>
/// A string representing the display name of the user; If the nickname is null, this will be the username.
/// </returns>
string DisplayName { get; }
/// <summary>
/// Gets the nickname for this user.
/// </summary>
/// <returns>
Expand Down
3 changes: 2 additions & 1 deletion src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public class RestGuildUser : RestUser, IGuildUser
private long? _timedOutTicks;
private long? _joinedAtTicks;
private ImmutableArray<ulong> _roleIds;

/// <inheritdoc />
public string DisplayName => Nickname ?? Username;
/// <inheritdoc />
public string Nickname { get; private set; }
/// <inheritdoc/>
Expand Down
2 changes: 2 additions & 0 deletions src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ IGuild IGuildUser.Guild
/// <inheritdoc />
DateTimeOffset? IGuildUser.JoinedAt => null;
/// <inheritdoc />
string IGuildUser.DisplayName => null;
/// <inheritdoc />
string IGuildUser.Nickname => null;
/// <inheritdoc />
string IGuildUser.GuildAvatarId => null;
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 @@ -30,6 +30,8 @@ public class SocketGuildUser : SocketUser, IGuildUser
/// </summary>
public SocketGuild Guild { get; }
/// <inheritdoc />
public string DisplayName => Nickname ?? Username;
/// <inheritdoc />
public string Nickname { get; private set; }
/// <inheritdoc/>
public string GuildAvatarId { get; private set; }
Expand Down
4 changes: 4 additions & 0 deletions src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ public class SocketThreadUser : SocketUser, IThreadUser, IGuildUser
public DateTimeOffset? JoinedAt
=> GuildUser.JoinedAt;

/// <inheritdoc/>
public string DisplayName
=> GuildUser.Nickname ?? GuildUser.Username;

/// <inheritdoc/>
public string Nickname
=> GuildUser.Nickname;
Expand Down
2 changes: 2 additions & 0 deletions src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ internal static SocketWebhookUser Create(SocketGuild guild, ClientState state, M
/// <inheritdoc />
DateTimeOffset? IGuildUser.JoinedAt => null;
/// <inheritdoc />
string IGuildUser.DisplayName => null;
/// <inheritdoc />
string IGuildUser.Nickname => null;
/// <inheritdoc />
string IGuildUser.GuildAvatarId => null;
Expand Down

0 comments on commit abfba3c

Please sign in to comment.