diff --git a/src/Discord.Net.Core/Entities/Users/IGuildUser.cs b/src/Discord.Net.Core/Entities/Users/IGuildUser.cs index 21f6cf093..96de06ed8 100644 --- a/src/Discord.Net.Core/Entities/Users/IGuildUser.cs +++ b/src/Discord.Net.Core/Entities/Users/IGuildUser.cs @@ -32,7 +32,15 @@ namespace Discord /// string Nickname { get; } /// - /// Gets the guild specific avatar for this users. + /// Gets the displayed avatar for this user. + /// + /// + /// The users displayed avatar hash. If the user does not have a guild avatar, this will be the regular avatar. + /// If the user also does not have a regular avatar, this will be . + /// + string DisplayAvatarId { get; } + /// + /// Gets the guild specific avatar for this user. /// /// /// The users guild avatar hash if they have one; otherwise . @@ -126,16 +134,29 @@ namespace Discord /// /// /// This property retrieves a URL for this guild user's guild specific avatar. In event that the user does not have a valid guild avatar - /// (i.e. their avatar identifier is not set), this method will return null. + /// (i.e. their avatar identifier is not set), this method will return . /// /// The format to return. /// The size of the image to return in. This can be any power of two between 16 and 2048. /// /// - /// A string representing the user's avatar URL; null if the user does not have an avatar in place. + /// A string representing the user's avatar URL; if the user does not have an avatar in place. /// string GetGuildAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128); /// + /// Gets the display avatar URL for this user. + /// + /// + /// This property retrieves an URL for this guild user's displayed avatar. + /// If the user does not have a guild avatar, this will be the user's regular avatar. + /// + /// The format to return. + /// The size of the image to return in. This can be any power of two between 16 and 2048. + /// + /// A string representing the URL of the displayed avatar for this user. if the user does not have an avatar in place. + /// + string GetDisplayAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128); + /// /// Kicks this user from this guild. /// /// The reason for the kick which will be recorded in the audit log. diff --git a/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs b/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs index 1415b5825..d6c7b5d7c 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestGuildUser.cs @@ -24,6 +24,8 @@ namespace Discord.Rest /// public string Nickname { get; private set; } /// + public string DisplayAvatarId => GuildAvatarId ?? AvatarId; + /// public string GuildAvatarId { get; private set; } internal IGuild Guild { get; private set; } /// @@ -183,6 +185,13 @@ namespace Discord.Rest return new ChannelPermissions(Permissions.ResolveChannel(Guild, this, channel, guildPerms.RawValue)); } + /// + public string GetDisplayAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) + => GuildAvatarId is not null + ? GetGuildAvatarUrl(format, size) + : GetAvatarUrl(format, size); + + /// public string GetGuildAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) => CDN.GetGuildUserAvatarUrl(Id, GuildId, GuildAvatarId, size, format); #endregion diff --git a/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs b/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs index b887f8df6..d03800676 100644 --- a/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs +++ b/src/Discord.Net.Rest/Entities/Users/RestWebhookUser.cs @@ -55,9 +55,13 @@ namespace Discord.Rest string IGuildUser.DisplayName => null; /// string IGuildUser.Nickname => null; + /// + string IGuildUser.DisplayAvatarId => null; /// string IGuildUser.GuildAvatarId => null; /// + string IGuildUser.GetDisplayAvatarUrl(ImageFormat format, ushort size) => null; + /// string IGuildUser.GetGuildAvatarUrl(ImageFormat format, ushort size) => null; /// bool? IGuildUser.IsPending => null; diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs index 52d55561f..ac3a53f17 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketGuildUser.cs @@ -34,6 +34,8 @@ namespace Discord.WebSocket /// public string Nickname { get; private set; } /// + public string DisplayAvatarId => GuildAvatarId ?? AvatarId; + /// public string GuildAvatarId { get; private set; } /// public override bool IsBot { get { return GlobalUser.IsBot; } internal set { GlobalUser.IsBot = value; } } @@ -246,6 +248,14 @@ namespace Discord.WebSocket /// public ChannelPermissions GetPermissions(IGuildChannel channel) => new ChannelPermissions(Permissions.ResolveChannel(Guild, this, channel, GuildPermissions.RawValue)); + + /// + public string GetDisplayAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) + => GuildAvatarId is not null + ? GetGuildAvatarUrl(format, size) + : GetAvatarUrl(format, size); + + /// public string GetGuildAvatarUrl(ImageFormat format = ImageFormat.Auto, ushort size = 128) => CDN.GetGuildUserAvatarUrl(Id, Guild.Id, GuildAvatarId, size, format); diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs index f3fdbff3e..08a1cbab4 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketThreadUser.cs @@ -58,6 +58,9 @@ namespace Discord.WebSocket get => GuildUser.AvatarId; internal set => GuildUser.AvatarId = value; } + /// + public string DisplayAvatarId => GuildAvatarId ?? AvatarId; + /// public string GuildAvatarId => GuildUser.GuildAvatarId; @@ -201,6 +204,10 @@ namespace Discord.WebSocket /// IReadOnlyCollection IGuildUser.RoleIds => GuildUser.Roles.Select(x => x.Id).ToImmutableArray(); + /// + string IGuildUser.GetDisplayAvatarUrl(ImageFormat format, ushort size) => GuildUser.GetDisplayAvatarUrl(format, size); + + /// string IGuildUser.GetGuildAvatarUrl(ImageFormat format, ushort size) => GuildUser.GetGuildAvatarUrl(format, size); internal override SocketGlobalUser GlobalUser { get => GuildUser.GlobalUser; set => GuildUser.GlobalUser = value; } diff --git a/src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs b/src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs index b6a00bcb0..df5fe786d 100644 --- a/src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs +++ b/src/Discord.Net.WebSocket/Entities/Users/SocketWebhookUser.cs @@ -67,8 +67,12 @@ namespace Discord.WebSocket /// string IGuildUser.Nickname => null; /// + string IGuildUser.DisplayAvatarId => null; + /// string IGuildUser.GuildAvatarId => null; /// + string IGuildUser.GetDisplayAvatarUrl(ImageFormat format, ushort size) => null; + /// string IGuildUser.GetGuildAvatarUrl(ImageFormat format, ushort size) => null; /// DateTimeOffset? IGuildUser.PremiumSince => null;