[Feature] Avatar decorations support (#2782)

* yup

* nullable...

* add props & methos to `GuildUser` & `IUser`
This commit is contained in:
Mihail Gribkov
2023-11-18 23:38:36 +03:00
committed by GitHub
parent b45b7743a5
commit f64d9d6f22
6 changed files with 90 additions and 0 deletions

View File

@@ -47,6 +47,13 @@ namespace Discord.WebSocket
public IReadOnlyCollection<ClientType> ActiveClients => Presence.ActiveClients ?? ImmutableHashSet<ClientType>.Empty;
/// <inheritdoc />
public IReadOnlyCollection<IActivity> Activities => Presence.Activities ?? ImmutableList<IActivity>.Empty;
/// <inheritdoc />
public string AvatarDecorationHash { get; private set; }
/// <inheritdoc />
public ulong? AvatarDecorationSkuId { get; private set; }
/// <summary>
/// Gets mutual guilds shared with this user.
/// </summary>
@@ -98,6 +105,14 @@ namespace Discord.WebSocket
GlobalName = model.GlobalName.Value;
hasChanges = true;
}
if (model.AvatarDecoration is { IsSpecified: true, Value: not null }
&& (model.AvatarDecoration.Value.Asset != AvatarDecorationHash || model.AvatarDecoration.Value.SkuId != AvatarDecorationSkuId))
{
AvatarDecorationHash = model.AvatarDecoration.Value?.Asset;
AvatarDecorationSkuId = model.AvatarDecoration.Value?.SkuId;
hasChanges = true;
}
return hasChanges;
}
@@ -121,6 +136,12 @@ namespace Discord.WebSocket
? CDN.GetDefaultUserAvatarUrl(DiscriminatorValue)
: CDN.GetDefaultUserAvatarUrl(Id);
/// <inheritdoc />
public string GetAvatarDecorationUrl()
=> AvatarDecorationHash is not null
? CDN.GetAvatarDecorationUrl(AvatarDecorationHash)
: null;
/// <summary>
/// Gets the full name of the user (e.g. Example#0001).
/// </summary>