Skip to content

Commit

Permalink
feat: avatar_decoration_data
Browse files Browse the repository at this point in the history
  • Loading branch information
Lulalaby committed Oct 17, 2023
1 parent 62ae3ab commit 57fe070
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
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
21 changes: 15 additions & 6 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 All @@ -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";

/// <summary>
/*/// <summary>
/// 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 => 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";*/

/// <summary>
/// Gets the URL of default avatar for this user.
Expand Down Expand Up @@ -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; }
}

/// <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

0 comments on commit 57fe070

Please sign in to comment.