[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:
32
src/Discord.Net.Rest/API/Common/SectionComponent.cs
Normal file
32
src/Discord.Net.Rest/API/Common/SectionComponent.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using Discord.Rest;
|
||||
using Newtonsoft.Json;
|
||||
using System.Linq;
|
||||
|
||||
namespace Discord.API;
|
||||
|
||||
internal class SectionComponent : IMessageComponent
|
||||
{
|
||||
[JsonProperty("type")]
|
||||
public ComponentType Type { get; set; }
|
||||
|
||||
[JsonProperty("id")]
|
||||
public Optional<int> Id { get; set; }
|
||||
|
||||
[JsonProperty("components")]
|
||||
public IMessageComponent[] Components { get; set; }
|
||||
|
||||
[JsonProperty("accessory")]
|
||||
public IMessageComponent Accessory { get; set; }
|
||||
|
||||
public SectionComponent() { }
|
||||
|
||||
public SectionComponent(Discord.SectionComponent component)
|
||||
{
|
||||
Type = component.Type;
|
||||
Id = component.Id ?? Optional<int>.Unspecified;
|
||||
Components = component.Components.Select(x => x.ToModel()).ToArray();
|
||||
Accessory = component.Accessory.ToModel();
|
||||
}
|
||||
|
||||
int? IMessageComponent.Id => Id.ToNullable();
|
||||
}
|
||||
Reference in New Issue
Block a user