Skip to content

Commit

Permalink
Merge branch 'main' into fix/vnext
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby authored Oct 21, 2023
2 parents d7c0990 + f189875 commit 80b7209
Show file tree
Hide file tree
Showing 12 changed files with 46 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions DisCatSharp.Hosting.Tests/DisCatSharp.Hosting.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
4 changes: 2 additions & 2 deletions DisCatSharp.Tests/SafetyTests/DisCatSharp.SafetyTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.7.0" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="4.7.0" />
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<PackageReference Include="xunit" Version="2.5.3" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
6 changes: 3 additions & 3 deletions DisCatSharp/Clients/DiscordClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ public async Task<DiscordUser> 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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions DisCatSharp/DisCatSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ Written with love and for everyone.
<PackageReference Include="Microsoft.Extensions.Logging" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="7.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="Sentry" Version="3.40.0" />
<PackageReference Include="Sentry.Extensions.Logging" Version="3.40.0" />
<PackageReference Include="Sentry" Version="3.40.1" />
<PackageReference Include="Sentry.Extensions.Logging" Version="3.40.1" />
<PackageReference Include="System.Memory" Version="4.5.5" />
<PackageReference Include="System.Net.Http" Version="4.3.4" />
<PackageReference Include="System.Net.WebSockets" Version="4.3.0" />
Expand Down
25 changes: 20 additions & 5 deletions DisCatSharp/Entities/User/DiscordUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>()).ToList();
Expand Down Expand Up @@ -155,10 +155,10 @@ public string BannerUrl
public virtual string AvatarHash { get; internal set; }

/// <summary>
/// Gets the user's avatar decoration hash.
/// Gets the user's avatar decoration data.
/// </summary>
[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; }

/// <summary>
/// Returns a uri to this users profile.
Expand Down Expand Up @@ -186,7 +186,7 @@ public string AvatarUrl
/// Gets the user's avatar decoration url.
/// </summary>
[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;

/// <summary>
/// Gets the URL of default avatar for this user.
Expand Down Expand Up @@ -580,6 +580,21 @@ public override string ToString()
=> !(e1 == e2);
}

public class AvatarDecorationData
{
[JsonProperty("asset", NullValueHandling = NullValueHandling.Ignore)]
public string Asset { get; internal set; }

/// <summary>
/// Gets the user's avatar decoration url.
/// </summary>
[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; }
}

/// <summary>
/// Represents a user comparer.
/// </summary>
Expand Down
11 changes: 7 additions & 4 deletions DisCatSharp/Net/Abstractions/Transport/TransportUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ internal string UsernameWithGlobalName
public string AvatarHash { get; internal set; }

/// <summary>
/// Gets the avatar decoration hash.
/// Gets the user's avatar decoration data.
/// </summary>
[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; }

/// <summary>
/// Gets the banner hash.
Expand Down Expand Up @@ -144,7 +144,10 @@ internal string UsernameWithGlobalName
/// Initializes a new instance of the <see cref="TransportUser"/> class.
/// </summary>
internal TransportUser()
: base(new() { "display_name", "linked_users", "banner_color" })
: base(new()
{
"display_name", "linked_users", "banner_color"
})
{ }

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion DisCatSharp/Net/Rest/Endpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ public static class Endpoints
/// <summary>
/// The avatar decorations endpoint.
/// </summary>
public const string AVATARS_DECORATIONS = "/avatars-decorations";
public const string AVATARS_DECORATION_PRESETS = "/avatar-decoration-presets";

/// <summary>
/// The bans endpoint.
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 80b7209

Please sign in to comment.