Skip to content

Add DisplayName property to IGuildUser. #2107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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