From 61fdee277697c4b85492f253154fbab59999f584 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Wed, 18 Oct 2023 17:35:41 +0200 Subject: [PATCH 1/3] feat!: Avatar Decoration Data (#378) * feat: avatar_decoration_data * add AvatarDecorationUrl * chore(deps): update packages --- .../DisCatSharp.Configuration.Tests.csproj | 4 +-- .../DisCatSharp.EventHandlers.Tests.csproj | 4 +-- .../DisCatSharp.Hosting.Tests.csproj | 4 +-- .../DisCatSharp.SafetyTests.csproj | 4 +-- DisCatSharp/Clients/DiscordClient.cs | 6 ++--- DisCatSharp/DisCatSharp.csproj | 4 +-- DisCatSharp/Entities/User/DiscordUser.cs | 25 +++++++++++++++---- .../Abstractions/Transport/TransportUser.cs | 11 +++++--- DisCatSharp/Net/Rest/Endpoints.cs | 2 +- 9 files changed, 41 insertions(+), 23 deletions(-) diff --git a/DisCatSharp.Configuration.Tests/DisCatSharp.Configuration.Tests.csproj b/DisCatSharp.Configuration.Tests/DisCatSharp.Configuration.Tests.csproj index aeadc29c6c..a311bc3705 100644 --- a/DisCatSharp.Configuration.Tests/DisCatSharp.Configuration.Tests.csproj +++ b/DisCatSharp.Configuration.Tests/DisCatSharp.Configuration.Tests.csproj @@ -19,8 +19,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/DisCatSharp.EventHandlers.Tests/DisCatSharp.EventHandlers.Tests.csproj b/DisCatSharp.EventHandlers.Tests/DisCatSharp.EventHandlers.Tests.csproj index e0254c18d4..e56239ed2f 100644 --- a/DisCatSharp.EventHandlers.Tests/DisCatSharp.EventHandlers.Tests.csproj +++ b/DisCatSharp.EventHandlers.Tests/DisCatSharp.EventHandlers.Tests.csproj @@ -10,8 +10,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/DisCatSharp.Hosting.Tests/DisCatSharp.Hosting.Tests.csproj b/DisCatSharp.Hosting.Tests/DisCatSharp.Hosting.Tests.csproj index e0200ac363..63217c6cd7 100644 --- a/DisCatSharp.Hosting.Tests/DisCatSharp.Hosting.Tests.csproj +++ b/DisCatSharp.Hosting.Tests/DisCatSharp.Hosting.Tests.csproj @@ -19,8 +19,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/DisCatSharp.Tests/SafetyTests/DisCatSharp.SafetyTests.csproj b/DisCatSharp.Tests/SafetyTests/DisCatSharp.SafetyTests.csproj index d1e58f79f7..086fcff378 100644 --- a/DisCatSharp.Tests/SafetyTests/DisCatSharp.SafetyTests.csproj +++ b/DisCatSharp.Tests/SafetyTests/DisCatSharp.SafetyTests.csproj @@ -18,8 +18,8 @@ - - + + runtime; build; native; contentfiles; analyzers; buildtransitive all diff --git a/DisCatSharp/Clients/DiscordClient.cs b/DisCatSharp/Clients/DiscordClient.cs index 63716bdb6b..7682e5c705 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/DisCatSharp.csproj b/DisCatSharp/DisCatSharp.csproj index cfbf9780d4..742e9742d6 100644 --- a/DisCatSharp/DisCatSharp.csproj +++ b/DisCatSharp/DisCatSharp.csproj @@ -37,8 +37,8 @@ Written with love and for everyone. - - + + diff --git a/DisCatSharp/Entities/User/DiscordUser.cs b/DisCatSharp/Entities/User/DiscordUser.cs index 0935b1a78a..df61dbbbbd 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. @@ -186,7 +186,7 @@ public string AvatarUrl /// 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 => this.AvatarDecorationData?.AssetUrl; /// /// Gets the URL of default avatar for this user. @@ -580,6 +580,21 @@ public override string ToString() => !(e1 == e2); } +public class AvatarDecorationData +{ + [JsonProperty("asset", NullValueHandling = NullValueHandling.Ignore)] + public string Asset { get; internal set; } + + /// + /// Gets the user's avatar decoration url. + /// + [JsonIgnore] + public string? AssetUrl => string.IsNullOrWhiteSpace(this.Asset) ? null : $"{DiscordDomain.GetDomain(CoreDomain.DiscordCdn).Url}{Endpoints.AVATARS_DECORATION_PRESETS}/{this.Asset}.png?size=1024"; + + [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 369d8f5765..ba9d28a9ab 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" + }) { } /// diff --git a/DisCatSharp/Net/Rest/Endpoints.cs b/DisCatSharp/Net/Rest/Endpoints.cs index a5fa70f0e0..0e31e533c9 100644 --- a/DisCatSharp/Net/Rest/Endpoints.cs +++ b/DisCatSharp/Net/Rest/Endpoints.cs @@ -202,7 +202,7 @@ public static class Endpoints /// /// The avatar decorations endpoint. /// - public const string AVATARS_DECORATIONS = "/avatars-decorations"; + public const string AVATARS_DECORATION_PRESETS = "/avatar-decoration-presets"; /// /// The bans endpoint. From 473e66491b6c66798ebc1ecc99e0ccd96c78dfa7 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Fri, 20 Oct 2023 16:47:28 +0200 Subject: [PATCH 2/3] [ci skip] chore(readme): add sentry sponser info Signed-off-by: Lala Sabathil --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index e831e0c8a9..30e57dbc3d 100644 --- a/README.md +++ b/README.md @@ -150,6 +150,9 @@ Big thanks goes to the following people who helped us without being part of the The special thanks goes to Nagisa. Make sure to check out her [Instagram](https://www.instagram.com/nagisaarts_/) ♥️♥️ +The second special thanks goes to [Sentry](https://sentry.io) ([GitHub](https://github.com/getsentry/)) for sponsering us a business account on sentry for error tracking. +You guys are the best 💕⭐ + ## Open Source License Status [![FOSSA Status](https://app.fossa.com/api/projects/git%2Bgithub.com%2FAiko-IT-Systems%2FDisCatSharp.svg?type=large)](https://app.fossa.com/reports/d18d903c-f217-4d82-a7ec-e113fb147275?ref=badge_large) From f189875114be8412a255c8e1c4400118081cc1d1 Mon Sep 17 00:00:00 2001 From: Lala Sabathil Date: Wed, 18 Oct 2023 18:54:12 +0200 Subject: [PATCH 3/3] fix(actions): pin docfx again.. --- .github/workflows/documentation.yml | 2 +- .github/workflows/documentation_test.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/documentation.yml b/.github/workflows/documentation.yml index dbac46cb43..fc06fdac54 100644 --- a/.github/workflows/documentation.yml +++ b/.github/workflows/documentation.yml @@ -25,7 +25,7 @@ jobs: - name: Git fetch unshallow run: git fetch --unshallow - name: Install DocFX - run: dotnet tool update -g docfx --prerelease + run: dotnet tool update -g docfx --version 2.71.0 - name: Restore packages run: dotnet restore DisCatSharp.sln - name: Build library diff --git a/.github/workflows/documentation_test.yml b/.github/workflows/documentation_test.yml index d396418d4c..d723e5cfa1 100644 --- a/.github/workflows/documentation_test.yml +++ b/.github/workflows/documentation_test.yml @@ -24,7 +24,7 @@ jobs: with: dotnet-version: 7.0.401 - name: Install DocFX - run: dotnet tool update -g docfx --prerelease + run: dotnet tool update -g docfx --version 2.71.0 continue-on-error: true - name: Restore packages run: dotnet restore DisCatSharp.sln