using Newtonsoft.Json; namespace Discord.API { internal class ButtonComponent : IInteractableComponent { [JsonProperty("type")] public ComponentType Type { get; set; } [JsonProperty("id")] public Optional Id { get; set; } [JsonProperty("style")] public ButtonStyle Style { get; set; } [JsonProperty("label")] public Optional Label { get; set; } [JsonProperty("emoji")] public Optional Emote { get; set; } [JsonProperty("custom_id")] public Optional CustomId { get; set; } [JsonProperty("url")] public Optional Url { get; set; } [JsonProperty("disabled")] public Optional Disabled { get; set; } [JsonProperty("sku_id")] public Optional SkuId { get; set; } public ButtonComponent() { } public ButtonComponent(Discord.ButtonComponent c) { Type = c.Type; Style = c.Style; Label = c.Label; CustomId = c.CustomId; Url = c.Url; Disabled = c.IsDisabled; SkuId = c.SkuId ?? Optional.Unspecified; Id = c.Id ?? Optional.Unspecified; if (c.Emote != null) { if (c.Emote is Emote e) { Emote = new Emoji { Name = e.Name, Animated = e.Animated, Id = e.Id }; } else { Emote = new Emoji { Name = c.Emote.Name }; } } } [JsonIgnore] string IInteractableComponent.CustomId => CustomId.GetValueOrDefault(); [JsonIgnore] int? IMessageComponent.Id => Id.ToNullable(); IMessageComponentBuilder IMessageComponent.ToBuilder() => null; } }