[Feature] Add Role & Attachment flags (#2720)
* initial commit * oops * another typo -_- * Update AttachmentFlags.cs Made this on my phone lol * Update AttachmentFlags.cs * -line
This commit is contained in:
@@ -1,32 +1,45 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API
|
||||
namespace Discord.API;
|
||||
|
||||
internal class Attachment
|
||||
{
|
||||
internal class Attachment
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public ulong Id { get; set; }
|
||||
[JsonProperty("filename")]
|
||||
public string Filename { get; set; }
|
||||
[JsonProperty("description")]
|
||||
public Optional<string> Description { get; set; }
|
||||
[JsonProperty("content_type")]
|
||||
public Optional<string> ContentType { get; set; }
|
||||
[JsonProperty("size")]
|
||||
public int Size { get; set; }
|
||||
[JsonProperty("url")]
|
||||
public string Url { get; set; }
|
||||
[JsonProperty("proxy_url")]
|
||||
public string ProxyUrl { get; set; }
|
||||
[JsonProperty("height")]
|
||||
public Optional<int> Height { get; set; }
|
||||
[JsonProperty("width")]
|
||||
public Optional<int> Width { get; set; }
|
||||
[JsonProperty("ephemeral")]
|
||||
public Optional<bool> Ephemeral { get; set; }
|
||||
[JsonProperty("duration_secs")]
|
||||
public Optional<double> DurationSeconds { get; set; }
|
||||
[JsonProperty("waveform")]
|
||||
public Optional<string> Waveform { get; set; }
|
||||
}
|
||||
[JsonProperty("id")]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
[JsonProperty("filename")]
|
||||
public string Filename { get; set; }
|
||||
|
||||
[JsonProperty("description")]
|
||||
public Optional<string> Description { get; set; }
|
||||
|
||||
[JsonProperty("content_type")]
|
||||
public Optional<string> ContentType { get; set; }
|
||||
|
||||
[JsonProperty("size")]
|
||||
public int Size { get; set; }
|
||||
|
||||
[JsonProperty("url")]
|
||||
public string Url { get; set; }
|
||||
|
||||
[JsonProperty("proxy_url")]
|
||||
public string ProxyUrl { get; set; }
|
||||
|
||||
[JsonProperty("height")]
|
||||
public Optional<int> Height { get; set; }
|
||||
|
||||
[JsonProperty("width")]
|
||||
public Optional<int> Width { get; set; }
|
||||
|
||||
[JsonProperty("ephemeral")]
|
||||
public Optional<bool> Ephemeral { get; set; }
|
||||
|
||||
[JsonProperty("duration_secs")]
|
||||
public Optional<double> DurationSeconds { get; set; }
|
||||
|
||||
[JsonProperty("waveform")]
|
||||
public Optional<string> Waveform { get; set; }
|
||||
|
||||
[JsonProperty("flags")]
|
||||
public Optional<AttachmentFlags> Flags { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,30 +1,42 @@
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API
|
||||
namespace Discord.API;
|
||||
|
||||
internal class Role
|
||||
{
|
||||
internal class Role
|
||||
{
|
||||
[JsonProperty("id")]
|
||||
public ulong Id { get; set; }
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
[JsonProperty("icon")]
|
||||
public Optional<string> Icon { get; set; }
|
||||
[JsonProperty("unicode_emoji")]
|
||||
public Optional<string> Emoji { get; set; }
|
||||
[JsonProperty("color")]
|
||||
public uint Color { get; set; }
|
||||
[JsonProperty("hoist")]
|
||||
public bool Hoist { get; set; }
|
||||
[JsonProperty("mentionable")]
|
||||
public bool Mentionable { get; set; }
|
||||
[JsonProperty("position")]
|
||||
public int Position { get; set; }
|
||||
[JsonProperty("permissions"), Int53]
|
||||
public string Permissions { get; set; }
|
||||
[JsonProperty("managed")]
|
||||
public bool Managed { get; set; }
|
||||
[JsonProperty("tags")]
|
||||
public Optional<RoleTags> Tags { get; set; }
|
||||
}
|
||||
[JsonProperty("id")]
|
||||
public ulong Id { get; set; }
|
||||
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("icon")]
|
||||
public Optional<string> Icon { get; set; }
|
||||
|
||||
[JsonProperty("unicode_emoji")]
|
||||
public Optional<string> Emoji { get; set; }
|
||||
|
||||
[JsonProperty("color")]
|
||||
public uint Color { get; set; }
|
||||
|
||||
[JsonProperty("hoist")]
|
||||
public bool Hoist { get; set; }
|
||||
|
||||
[JsonProperty("mentionable")]
|
||||
public bool Mentionable { get; set; }
|
||||
|
||||
[JsonProperty("position")]
|
||||
public int Position { get; set; }
|
||||
|
||||
[JsonProperty("permissions"), Int53]
|
||||
public string Permissions { get; set; }
|
||||
|
||||
[JsonProperty("managed")]
|
||||
public bool Managed { get; set; }
|
||||
|
||||
[JsonProperty("tags")]
|
||||
public Optional<RoleTags> Tags { get; set; }
|
||||
|
||||
[JsonProperty("flags")]
|
||||
public RoleFlags Flags { get; set; }
|
||||
}
|
||||
|
||||
@@ -32,8 +32,11 @@ namespace Discord
|
||||
/// <inheritdoc />
|
||||
public double? Duration { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public AttachmentFlags Flags { get; }
|
||||
|
||||
internal Attachment(ulong id, string filename, string url, string proxyUrl, int size, int? height, int? width,
|
||||
bool? ephemeral, string description, string contentType, double? duration, string waveform)
|
||||
bool? ephemeral, string description, string contentType, double? duration, string waveform, AttachmentFlags flags)
|
||||
{
|
||||
Id = id;
|
||||
Filename = filename;
|
||||
@@ -47,6 +50,7 @@ namespace Discord
|
||||
ContentType = contentType;
|
||||
Duration = duration;
|
||||
Waveform = waveform;
|
||||
Flags = flags;
|
||||
}
|
||||
internal static Attachment Create(Model model)
|
||||
{
|
||||
@@ -56,7 +60,8 @@ namespace Discord
|
||||
model.Ephemeral.ToNullable(), model.Description.GetValueOrDefault(),
|
||||
model.ContentType.GetValueOrDefault(),
|
||||
model.DurationSeconds.IsSpecified ? model.DurationSeconds.Value : null,
|
||||
model.Waveform.GetValueOrDefault(null));
|
||||
model.Waveform.GetValueOrDefault(null),
|
||||
model.Flags.GetValueOrDefault(AttachmentFlags.None));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -34,6 +34,9 @@ namespace Discord.Rest
|
||||
/// <inheritdoc />
|
||||
public RoleTags Tags { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public RoleFlags Flags { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
|
||||
/// <summary>
|
||||
@@ -63,6 +66,8 @@ namespace Discord.Rest
|
||||
Position = model.Position;
|
||||
Color = new Color(model.Color);
|
||||
Permissions = new GuildPermissions(model.Permissions);
|
||||
Flags = model.Flags;
|
||||
|
||||
if (model.Tags.IsSpecified)
|
||||
Tags = model.Tags.Value.ToEntity();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user