Add DisplayName property to IGuildUser. (#2107)

This commit is contained in:
Armano den Boef
2022-02-16 12:52:08 +01:00
committed by GitHub
parent 169d54f1df
commit abfba3c4bb
6 changed files with 19 additions and 1 deletions

View File

@@ -18,6 +18,13 @@ namespace Discord
/// </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>

View File

@@ -19,7 +19,8 @@ namespace Discord.Rest
private long? _timedOutTicks;
private long? _joinedAtTicks;
private ImmutableArray<ulong> _roleIds;
/// <inheritdoc />
public string DisplayName => Nickname ?? Username;
/// <inheritdoc />
public string Nickname { get; private set; }
/// <inheritdoc/>

View File

@@ -52,6 +52,8 @@ namespace Discord.Rest
/// <inheritdoc />
DateTimeOffset? IGuildUser.JoinedAt => null;
/// <inheritdoc />
string IGuildUser.DisplayName => null;
/// <inheritdoc />
string IGuildUser.Nickname => null;
/// <inheritdoc />
string IGuildUser.GuildAvatarId => null;

View File

@@ -30,6 +30,8 @@ namespace Discord.WebSocket
/// </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; }

View File

@@ -29,6 +29,10 @@ namespace Discord.WebSocket
public DateTimeOffset? JoinedAt
=> GuildUser.JoinedAt;
/// <inheritdoc/>
public string DisplayName
=> GuildUser.Nickname ?? GuildUser.Username;
/// <inheritdoc/>
public string Nickname
=> GuildUser.Nickname;

View File

@@ -63,6 +63,8 @@ namespace Discord.WebSocket
/// <inheritdoc />
DateTimeOffset? IGuildUser.JoinedAt => null;
/// <inheritdoc />
string IGuildUser.DisplayName => null;
/// <inheritdoc />
string IGuildUser.Nickname => null;
/// <inheritdoc />
string IGuildUser.GuildAvatarId => null;