[Feature] Components V2 (#3065)

* oh well. at least it runs

* well that's some breakings

* all the models (i think)

* barebones builder impl

* commit

* initial take on `WithX` component builder design

* actually usable stuff now

* few more changes

* fixes, changes, syntax sugar

* rework message flags + auto add `ComponentsV2`

* apparently it's also nullable

* fix build

* webhook component supports + builder validations + some xmldoc

* `ResolvedUnfurledMediaItem` + fix missing accessory on sections

* missing xmldoc

* fix modal + whatever change

* yeet unused dep
This commit is contained in:
Mihail Gribkov
2025-04-26 23:40:03 +03:00
committed by GitHub
parent 5e4a844adf
commit ba78e0c1f0
102 changed files with 2852 additions and 692 deletions

View File

@@ -2,11 +2,14 @@ using Newtonsoft.Json;
namespace Discord.API
{
internal class ButtonComponent : IMessageComponent
internal class ButtonComponent : IInteractableComponent
{
[JsonProperty("type")]
public ComponentType Type { get; set; }
[JsonProperty("id")]
public Optional<int> Id { get; set; }
[JsonProperty("style")]
public ButtonStyle Style { get; set; }
@@ -39,6 +42,7 @@ namespace Discord.API
Url = c.Url;
Disabled = c.IsDisabled;
SkuId = c.SkuId ?? Optional<ulong>.Unspecified;
Id = c.Id ?? Optional<int>.Unspecified;
if (c.Emote != null)
{
@@ -62,6 +66,9 @@ namespace Discord.API
}
[JsonIgnore]
string IMessageComponent.CustomId => CustomId.GetValueOrDefault();
string IInteractableComponent.CustomId => CustomId.GetValueOrDefault();
[JsonIgnore]
int? IMessageComponent.Id => Id.ToNullable();
}
}