From 57fe070e3fb154fafe255273e204943b6925bf73 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Tue, 17 Oct 2023 06:41:37 +0200 Subject: [PATCH] feat: avatar_decoration_data --- DisCatSharp/Clients/DiscordClient.cs | 6 +++--- DisCatSharp/Entities/User/DiscordUser.cs | 21 +++++++++++++------ .../Abstractions/Transport/TransportUser.cs | 11 ++++++---- 3 files changed, 25 insertions(+), 13 deletions(-) diff --git a/DisCatSharp/Clients/DiscordClient.cs b/DisCatSharp/Clients/DiscordClient.cs index 63716bdb6..7682e5c70 100644 --- a/DisCatSharp/Clients/DiscordClient.cs +++ b/DisCatSharp/Clients/DiscordClient.cs @@ -404,7 +404,7 @@ public async Task GetUserAsync(ulong userId, bool fetch = false) old.AvatarHash = usr.AvatarHash; old.BannerHash = usr.BannerHash; old.BannerColorInternal = usr.BannerColorInternal; - old.AvatarDecorationHash = usr.AvatarDecorationHash; + old.AvatarDecorationData = usr.AvatarDecorationData; old.ThemeColorsInternal = usr.ThemeColorsInternal; old.Pronouns = usr.Pronouns; old.GlobalName = usr.GlobalName; @@ -1370,7 +1370,7 @@ private DiscordUser UpdateUser(DiscordUser usr, ulong? guildId, DiscordGuild gui old.AvatarHash = usr.AvatarHash; old.BannerHash = usr.BannerHash; old.BannerColorInternal = usr.BannerColorInternal; - old.AvatarDecorationHash = usr.AvatarDecorationHash; + old.AvatarDecorationData = usr.AvatarDecorationData; old.ThemeColorsInternal = usr.ThemeColorsInternal; old.Pronouns = usr.Pronouns; old.Locale = usr.Locale; @@ -1412,7 +1412,7 @@ private DiscordUser UpdateUser(DiscordUser usr, ulong? guildId, DiscordGuild gui old.AvatarHash = usr.AvatarHash; old.BannerHash = usr.BannerHash; old.BannerColorInternal = usr.BannerColorInternal; - old.AvatarDecorationHash = usr.AvatarDecorationHash; + old.AvatarDecorationData = usr.AvatarDecorationData; old.ThemeColorsInternal = usr.ThemeColorsInternal; old.Pronouns = usr.Pronouns; old.Locale = usr.Locale; diff --git a/DisCatSharp/Entities/User/DiscordUser.cs b/DisCatSharp/Entities/User/DiscordUser.cs index 0935b1a78..6744566bf 100644 --- a/DisCatSharp/Entities/User/DiscordUser.cs +++ b/DisCatSharp/Entities/User/DiscordUser.cs @@ -36,7 +36,7 @@ internal DiscordUser(TransportUser transport) this.Username = transport.Username; this.Discriminator = transport.Discriminator; this.AvatarHash = transport.AvatarHash; - this.AvatarDecorationHash = transport.AvatarDecorationHash; + this.AvatarDecorationData = transport.AvatarDecorationData; this.BannerHash = transport.BannerHash; this.BannerColorInternal = transport.BannerColor; this.ThemeColorsInternal = (transport.ThemeColors ?? Array.Empty()).ToList(); @@ -155,10 +155,10 @@ public string BannerUrl public virtual string AvatarHash { get; internal set; } /// - /// Gets the user's avatar decoration hash. + /// Gets the user's avatar decoration data. /// - [JsonProperty("avatar_decoration", NullValueHandling = NullValueHandling.Ignore)] - public virtual string AvatarDecorationHash { get; internal set; } + [JsonProperty("avatar_decoration_data", NullValueHandling = NullValueHandling.Ignore)] + public virtual AvatarDecorationData AvatarDecorationData { get; internal set; } /// /// Returns a uri to this users profile. @@ -182,11 +182,11 @@ public string ProfileUrl public string AvatarUrl => string.IsNullOrWhiteSpace(this.AvatarHash) ? this.DefaultAvatarUrl : $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Url}{Endpoints.AVATARS}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.AvatarHash}.{(this.AvatarHash.StartsWith("a_") ? "gif" : "png")}?size=1024"; - /// + /*/// /// Gets the user's avatar decoration url. /// [JsonIgnore] - public string? AvatarDecorationUrl => string.IsNullOrWhiteSpace(this.AvatarDecorationHash) ? null : $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Url}{Endpoints.AVATARS_DECORATIONS}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.AvatarDecorationHash}.{(this.AvatarDecorationHash.StartsWith("a_") ? "gif" : "png")}?size=1024"; + public string? AvatarDecorationUrl => string.IsNullOrWhiteSpace(this.AvatarDecorationHash) ? null : $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Url}{Endpoints.AVATARS_DECORATIONS}/{this.Id.ToString(CultureInfo.InvariantCulture)}/{this.AvatarDecorationHash}.{(this.AvatarDecorationHash.StartsWith("a_") ? "gif" : "png")}?size=1024";*/ /// /// Gets the URL of default avatar for this user. @@ -580,6 +580,15 @@ public override string ToString() => !(e1 == e2); } +public class AvatarDecorationData +{ + [JsonProperty("asset", NullValueHandling = NullValueHandling.Ignore)] + public string Asset { get; internal set; } + + [JsonProperty("sku_id", NullValueHandling = NullValueHandling.Ignore)] + public ulong SkuId { get; internal set; } +} + /// /// Represents a user comparer. /// diff --git a/DisCatSharp/Net/Abstractions/Transport/TransportUser.cs b/DisCatSharp/Net/Abstractions/Transport/TransportUser.cs index 369d8f576..ba9d28a9a 100644 --- a/DisCatSharp/Net/Abstractions/Transport/TransportUser.cs +++ b/DisCatSharp/Net/Abstractions/Transport/TransportUser.cs @@ -56,10 +56,10 @@ internal string UsernameWithGlobalName public string AvatarHash { get; internal set; } /// - /// Gets the avatar decoration hash. + /// Gets the user's avatar decoration data. /// - [JsonProperty("avatar_decoration", NullValueHandling = NullValueHandling.Ignore)] - public string AvatarDecorationHash { get; internal set; } + [JsonProperty("avatar_decoration_data", NullValueHandling = NullValueHandling.Ignore)] + public AvatarDecorationData AvatarDecorationData { get; internal set; } /// /// Gets the banner hash. @@ -144,7 +144,10 @@ internal string UsernameWithGlobalName /// Initializes a new instance of the class. /// internal TransportUser() - : base(new() { "display_name", "linked_users", "banner_color" }) + : base(new() + { + "display_name", "linked_users", "banner_color" + }) { } ///