Skip to content

Commit

Permalink
add IsAvailable to GuildEmote
Browse files Browse the repository at this point in the history
  • Loading branch information
Misha-133 committed Jun 29, 2024
1 parent 85a13e9 commit cb79f04
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 20 deletions.
9 changes: 8 additions & 1 deletion src/Discord.Net.Core/Entities/Emotes/GuildEmote.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,22 @@ public class GuildEmote : Emote
/// </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>
Expand Down
44 changes: 26 additions & 18 deletions src/Discord.Net.Rest/API/Common/Emoji.cs
Original file line number Diff line number Diff line change
@@ -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> 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> User { get; set; }

[JsonProperty("available")]
public Optional<bool> IsAvailable { get; set; }
}
3 changes: 2 additions & 1 deletion src/Discord.Net.Rest/Extensions/EntityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit cb79f04

Please sign in to comment.