From cb79f04b93888a429b99bafd083dacd28ece234a Mon Sep 17 00:00:00 2001 From: Mihail Gribkov <61027276+Misha-133@users.noreply.github.com> Date: Sat, 29 Jun 2024 20:20:41 +0300 Subject: [PATCH] add IsAvailable to GuildEmote --- .../Entities/Emotes/GuildEmote.cs | 9 +++- src/Discord.Net.Rest/API/Common/Emoji.cs | 44 +++++++++++-------- .../Extensions/EntityExtensions.cs | 3 +- 3 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/Discord.Net.Core/Entities/Emotes/GuildEmote.cs b/src/Discord.Net.Core/Entities/Emotes/GuildEmote.cs index 47ec3a424c..44a0b6caa6 100644 --- a/src/Discord.Net.Core/Entities/Emotes/GuildEmote.cs +++ b/src/Discord.Net.Core/Entities/Emotes/GuildEmote.cs @@ -39,15 +39,22 @@ public class GuildEmote : Emote /// public ulong? CreatorId { get; } - internal GuildEmote(ulong id, string name, bool animated, bool isManaged, bool requireColons, IReadOnlyList roleIds, ulong? userId) : base(id, name, animated) + /// + /// Gets whether this emoji is available. if unknown. + /// + public bool? IsAvailable { get; } + + internal GuildEmote(ulong id, string name, bool animated, bool isManaged, bool requireColons, IReadOnlyList roleIds, ulong? userId, bool? isAvailable) : base(id, name, animated) { IsManaged = isManaged; RequireColons = requireColons; RoleIds = roleIds; CreatorId = userId; + IsAvailable = isAvailable; } private string DebuggerDisplay => $"{Name} ({Id})"; + /// /// Gets the raw representation of the emote. /// diff --git a/src/Discord.Net.Rest/API/Common/Emoji.cs b/src/Discord.Net.Rest/API/Common/Emoji.cs index ff0baa73e9..d35b42ad49 100644 --- a/src/Discord.Net.Rest/API/Common/Emoji.cs +++ b/src/Discord.Net.Rest/API/Common/Emoji.cs @@ -1,22 +1,30 @@ using Newtonsoft.Json; -namespace Discord.API +namespace Discord.API; + +internal class Emoji { - internal class Emoji - { - [JsonProperty("id")] - public ulong? Id { get; set; } - [JsonProperty("name")] - public string Name { get; set; } - [JsonProperty("animated")] - public bool? Animated { get; set; } - [JsonProperty("roles")] - public ulong[] Roles { get; set; } - [JsonProperty("require_colons")] - public bool RequireColons { get; set; } - [JsonProperty("managed")] - public bool Managed { get; set; } - [JsonProperty("user")] - public Optional User { get; set; } - } + [JsonProperty("id")] + public ulong? Id { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + [JsonProperty("animated")] + public bool? Animated { get; set; } + + [JsonProperty("roles")] + public ulong[] Roles { get; set; } + + [JsonProperty("require_colons")] + public bool RequireColons { get; set; } + + [JsonProperty("managed")] + public bool Managed { get; set; } + + [JsonProperty("user")] + public Optional User { get; set; } + + [JsonProperty("available")] + public Optional IsAvailable { get; set; } } diff --git a/src/Discord.Net.Rest/Extensions/EntityExtensions.cs b/src/Discord.Net.Rest/Extensions/EntityExtensions.cs index 34d279ecd5..885d0f0807 100644 --- a/src/Discord.Net.Rest/Extensions/EntityExtensions.cs +++ b/src/Discord.Net.Rest/Extensions/EntityExtensions.cs @@ -20,7 +20,8 @@ public static GuildEmote ToEntity(this API.Emoji model) model.Managed, model.RequireColons, ImmutableArray.Create(model.Roles), - model.User.IsSpecified ? model.User.Value.Id : (ulong?)null); + model.User.IsSpecified ? model.User.Value.Id : null, + model.IsAvailable.ToNullable()); public static Embed ToEntity(this API.Embed model) {