Skip to content

Commit abfba3c

Browse files
authored
Add DisplayName property to IGuildUser. (#2107)
1 parent 169d54f commit abfba3c

File tree

6 files changed

+19
-1
lines changed

6 files changed

+19
-1
lines changed

src/Discord.Net.Core/Entities/Users/IGuildUser.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ public interface IGuildUser : IUser, IVoiceState
1818
/// </returns>
1919
DateTimeOffset? JoinedAt { get; }
2020
/// <summary>
21+
/// Gets the displayed name for this user.
22+
/// </summary>
23+
/// <returns>
24+
/// A string representing the display name of the user; If the nickname is null, this will be the username.
25+
/// </returns>
26+
string DisplayName { get; }
27+
/// <summary>
2128
/// Gets the nickname for this user.
2229
/// </summary>
2330
/// <returns>

src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public class RestGuildUser : RestUser, IGuildUser
1919
private long? _timedOutTicks;
2020
private long? _joinedAtTicks;
2121
private ImmutableArray<ulong> _roleIds;
22-
22+
/// <inheritdoc />
23+
public string DisplayName => Nickname ?? Username;
2324
/// <inheritdoc />
2425
public string Nickname { get; private set; }
2526
/// <inheritdoc/>

src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ IGuild IGuildUser.Guild
5252
/// <inheritdoc />
5353
DateTimeOffset? IGuildUser.JoinedAt => null;
5454
/// <inheritdoc />
55+
string IGuildUser.DisplayName => null;
56+
/// <inheritdoc />
5557
string IGuildUser.Nickname => null;
5658
/// <inheritdoc />
5759
string IGuildUser.GuildAvatarId => null;

src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public class SocketGuildUser : SocketUser, IGuildUser
3030
/// </summary>
3131
public SocketGuild Guild { get; }
3232
/// <inheritdoc />
33+
public string DisplayName => Nickname ?? Username;
34+
/// <inheritdoc />
3335
public string Nickname { get; private set; }
3436
/// <inheritdoc/>
3537
public string GuildAvatarId { get; private set; }

src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ public class SocketThreadUser : SocketUser, IThreadUser, IGuildUser
2929
public DateTimeOffset? JoinedAt
3030
=> GuildUser.JoinedAt;
3131

32+
/// <inheritdoc/>
33+
public string DisplayName
34+
=> GuildUser.Nickname ?? GuildUser.Username;
35+
3236
/// <inheritdoc/>
3337
public string Nickname
3438
=> GuildUser.Nickname;

src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ internal static SocketWebhookUser Create(SocketGuild guild, ClientState state, M
6363
/// <inheritdoc />
6464
DateTimeOffset? IGuildUser.JoinedAt => null;
6565
/// <inheritdoc />
66+
string IGuildUser.DisplayName => null;
67+
/// <inheritdoc />
6668
string IGuildUser.Nickname => null;
6769
/// <inheritdoc />
6870
string IGuildUser.GuildAvatarId => null;

0 commit comments

Comments
 (0)