add IsAvailable to GuildEmote

This commit is contained in:
Mihail Gribkov
2024-06-29 20:20:41 +03:00
committed by GitHub
parent 85a13e9fff
commit cb79f04b93
3 changed files with 36 additions and 20 deletions

View File

@@ -39,15 +39,22 @@ namespace Discord
/// </returns> /// </returns>
public ulong? CreatorId { get; } public ulong? CreatorId { get; }
internal GuildEmote(ulong id, string name, bool animated, bool isManaged, bool requireColons, IReadOnlyList<ulong> roleIds, ulong? userId) : base(id, name, animated) /// <summary>
/// Gets whether this emoji is available. <see langword="null" /> if unknown.
/// </summary>
public bool? IsAvailable { get; }
internal GuildEmote(ulong id, string name, bool animated, bool isManaged, bool requireColons, IReadOnlyList<ulong> roleIds, ulong? userId, bool? isAvailable) : base(id, name, animated)
{ {
IsManaged = isManaged; IsManaged = isManaged;
RequireColons = requireColons; RequireColons = requireColons;
RoleIds = roleIds; RoleIds = roleIds;
CreatorId = userId; CreatorId = userId;
IsAvailable = isAvailable;
} }
private string DebuggerDisplay => $"{Name} ({Id})"; private string DebuggerDisplay => $"{Name} ({Id})";
/// <summary> /// <summary>
/// Gets the raw representation of the emote. /// Gets the raw representation of the emote.
/// </summary> /// </summary>

View File

@@ -1,22 +1,30 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Discord.API namespace Discord.API;
internal class Emoji
{ {
internal class Emoji [JsonProperty("id")]
{ public ulong? Id { get; set; }
[JsonProperty("id")]
public ulong? Id { get; set; } [JsonProperty("name")]
[JsonProperty("name")] public string Name { get; set; }
public string Name { get; set; }
[JsonProperty("animated")] [JsonProperty("animated")]
public bool? Animated { get; set; } public bool? Animated { get; set; }
[JsonProperty("roles")]
public ulong[] Roles { get; set; } [JsonProperty("roles")]
[JsonProperty("require_colons")] public ulong[] Roles { get; set; }
public bool RequireColons { get; set; }
[JsonProperty("managed")] [JsonProperty("require_colons")]
public bool Managed { get; set; } public bool RequireColons { get; set; }
[JsonProperty("user")]
public Optional<User> User { get; set; } [JsonProperty("managed")]
} public bool Managed { get; set; }
[JsonProperty("user")]
public Optional<User> User { get; set; }
[JsonProperty("available")]
public Optional<bool> IsAvailable { get; set; }
} }

View File

@@ -20,7 +20,8 @@ namespace Discord.Rest
model.Managed, model.Managed,
model.RequireColons, model.RequireColons,
ImmutableArray.Create(model.Roles), 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) public static Embed ToEntity(this API.Embed model)
{ {