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>
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;
RequireColons = requireColons;
RoleIds = roleIds;
CreatorId = userId;
IsAvailable = isAvailable;
}
private string DebuggerDisplay => $"{Name} ({Id})";
/// <summary>
/// Gets the raw representation of the emote.
/// </summary>

View File

@@ -1,22 +1,30 @@
using Newtonsoft.Json;
namespace Discord.API
{
namespace Discord.API;
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> User { get; set; }
}
[JsonProperty("available")]
public Optional<bool> IsAvailable { get; set; }
}

View File

@@ -20,7 +20,8 @@ namespace Discord.Rest
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)
{