[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:
27
src/Discord.Net.Core/Entities/Messages/AttachmentFlags.cs
Normal file
27
src/Discord.Net.Core/Entities/Messages/AttachmentFlags.cs
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Discord;
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum AttachmentFlags
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The attachment has no flags.
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates that this attachment is a clip.
|
||||||
|
/// </summary>
|
||||||
|
IsClip = 1 << 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates that this attachment is a thumbnail.
|
||||||
|
/// </summary>
|
||||||
|
IsThumbnail = 1 << 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates that this attachment has been edited using the remix feature on mobile.
|
||||||
|
/// </summary>
|
||||||
|
IsRemix = 1 << 2,
|
||||||
|
}
|
||||||
@@ -80,5 +80,10 @@ namespace Discord
|
|||||||
/// Gets the base64 encoded bytearray representing a sampled waveform. <see langword="null"/> if the attachment is not a voice message.
|
/// Gets the base64 encoded bytearray representing a sampled waveform. <see langword="null"/> if the attachment is not a voice message.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string Waveform { get; }
|
public string Waveform { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets flags related to this to this attachment.
|
||||||
|
/// </summary>
|
||||||
|
public AttachmentFlags Flags { get; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -87,6 +87,11 @@ namespace Discord
|
|||||||
/// </returns>
|
/// </returns>
|
||||||
RoleTags Tags { get; }
|
RoleTags Tags { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets flags related to this role.
|
||||||
|
/// </summary>
|
||||||
|
RoleFlags Flags { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Modifies this role.
|
/// Modifies this role.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
17
src/Discord.Net.Core/Entities/Roles/RoleFlags.cs
Normal file
17
src/Discord.Net.Core/Entities/Roles/RoleFlags.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Discord;
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
public enum RoleFlags
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The role has no flags.
|
||||||
|
/// </summary>
|
||||||
|
None = 0,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Indicates that the role can be selected by members in an onboarding.
|
||||||
|
/// </summary>
|
||||||
|
InPrompt = 1 << 0,
|
||||||
|
}
|
||||||
@@ -1,32 +1,45 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Discord.API
|
namespace Discord.API;
|
||||||
{
|
|
||||||
internal class Attachment
|
internal class Attachment
|
||||||
{
|
{
|
||||||
[JsonProperty("id")]
|
[JsonProperty("id")]
|
||||||
public ulong Id { get; set; }
|
public ulong Id { get; set; }
|
||||||
|
|
||||||
[JsonProperty("filename")]
|
[JsonProperty("filename")]
|
||||||
public string Filename { get; set; }
|
public string Filename { get; set; }
|
||||||
|
|
||||||
[JsonProperty("description")]
|
[JsonProperty("description")]
|
||||||
public Optional<string> Description { get; set; }
|
public Optional<string> Description { get; set; }
|
||||||
|
|
||||||
[JsonProperty("content_type")]
|
[JsonProperty("content_type")]
|
||||||
public Optional<string> ContentType { get; set; }
|
public Optional<string> ContentType { get; set; }
|
||||||
|
|
||||||
[JsonProperty("size")]
|
[JsonProperty("size")]
|
||||||
public int Size { get; set; }
|
public int Size { get; set; }
|
||||||
|
|
||||||
[JsonProperty("url")]
|
[JsonProperty("url")]
|
||||||
public string Url { get; set; }
|
public string Url { get; set; }
|
||||||
|
|
||||||
[JsonProperty("proxy_url")]
|
[JsonProperty("proxy_url")]
|
||||||
public string ProxyUrl { get; set; }
|
public string ProxyUrl { get; set; }
|
||||||
|
|
||||||
[JsonProperty("height")]
|
[JsonProperty("height")]
|
||||||
public Optional<int> Height { get; set; }
|
public Optional<int> Height { get; set; }
|
||||||
|
|
||||||
[JsonProperty("width")]
|
[JsonProperty("width")]
|
||||||
public Optional<int> Width { get; set; }
|
public Optional<int> Width { get; set; }
|
||||||
|
|
||||||
[JsonProperty("ephemeral")]
|
[JsonProperty("ephemeral")]
|
||||||
public Optional<bool> Ephemeral { get; set; }
|
public Optional<bool> Ephemeral { get; set; }
|
||||||
|
|
||||||
[JsonProperty("duration_secs")]
|
[JsonProperty("duration_secs")]
|
||||||
public Optional<double> DurationSeconds { get; set; }
|
public Optional<double> DurationSeconds { get; set; }
|
||||||
|
|
||||||
[JsonProperty("waveform")]
|
[JsonProperty("waveform")]
|
||||||
public Optional<string> Waveform { get; set; }
|
public Optional<string> Waveform { get; set; }
|
||||||
}
|
|
||||||
|
[JsonProperty("flags")]
|
||||||
|
public Optional<AttachmentFlags> Flags { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,42 @@
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Discord.API
|
namespace Discord.API;
|
||||||
{
|
|
||||||
internal class Role
|
internal class Role
|
||||||
{
|
{
|
||||||
[JsonProperty("id")]
|
[JsonProperty("id")]
|
||||||
public ulong Id { get; set; }
|
public ulong Id { get; set; }
|
||||||
|
|
||||||
[JsonProperty("name")]
|
[JsonProperty("name")]
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
[JsonProperty("icon")]
|
[JsonProperty("icon")]
|
||||||
public Optional<string> Icon { get; set; }
|
public Optional<string> Icon { get; set; }
|
||||||
|
|
||||||
[JsonProperty("unicode_emoji")]
|
[JsonProperty("unicode_emoji")]
|
||||||
public Optional<string> Emoji { get; set; }
|
public Optional<string> Emoji { get; set; }
|
||||||
|
|
||||||
[JsonProperty("color")]
|
[JsonProperty("color")]
|
||||||
public uint Color { get; set; }
|
public uint Color { get; set; }
|
||||||
|
|
||||||
[JsonProperty("hoist")]
|
[JsonProperty("hoist")]
|
||||||
public bool Hoist { get; set; }
|
public bool Hoist { get; set; }
|
||||||
|
|
||||||
[JsonProperty("mentionable")]
|
[JsonProperty("mentionable")]
|
||||||
public bool Mentionable { get; set; }
|
public bool Mentionable { get; set; }
|
||||||
|
|
||||||
[JsonProperty("position")]
|
[JsonProperty("position")]
|
||||||
public int Position { get; set; }
|
public int Position { get; set; }
|
||||||
|
|
||||||
[JsonProperty("permissions"), Int53]
|
[JsonProperty("permissions"), Int53]
|
||||||
public string Permissions { get; set; }
|
public string Permissions { get; set; }
|
||||||
|
|
||||||
[JsonProperty("managed")]
|
[JsonProperty("managed")]
|
||||||
public bool Managed { get; set; }
|
public bool Managed { get; set; }
|
||||||
|
|
||||||
[JsonProperty("tags")]
|
[JsonProperty("tags")]
|
||||||
public Optional<RoleTags> Tags { get; set; }
|
public Optional<RoleTags> Tags { get; set; }
|
||||||
}
|
|
||||||
|
[JsonProperty("flags")]
|
||||||
|
public RoleFlags Flags { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,8 +32,11 @@ namespace Discord
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public double? Duration { get; }
|
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,
|
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;
|
Id = id;
|
||||||
Filename = filename;
|
Filename = filename;
|
||||||
@@ -47,6 +50,7 @@ namespace Discord
|
|||||||
ContentType = contentType;
|
ContentType = contentType;
|
||||||
Duration = duration;
|
Duration = duration;
|
||||||
Waveform = waveform;
|
Waveform = waveform;
|
||||||
|
Flags = flags;
|
||||||
}
|
}
|
||||||
internal static Attachment Create(Model model)
|
internal static Attachment Create(Model model)
|
||||||
{
|
{
|
||||||
@@ -56,7 +60,8 @@ namespace Discord
|
|||||||
model.Ephemeral.ToNullable(), model.Description.GetValueOrDefault(),
|
model.Ephemeral.ToNullable(), model.Description.GetValueOrDefault(),
|
||||||
model.ContentType.GetValueOrDefault(),
|
model.ContentType.GetValueOrDefault(),
|
||||||
model.DurationSeconds.IsSpecified ? model.DurationSeconds.Value : null,
|
model.DurationSeconds.IsSpecified ? model.DurationSeconds.Value : null,
|
||||||
model.Waveform.GetValueOrDefault(null));
|
model.Waveform.GetValueOrDefault(null),
|
||||||
|
model.Flags.GetValueOrDefault(AttachmentFlags.None));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ namespace Discord.Rest
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public RoleTags Tags { get; private set; }
|
public RoleTags Tags { get; private set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public RoleFlags Flags { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
|
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -63,6 +66,8 @@ namespace Discord.Rest
|
|||||||
Position = model.Position;
|
Position = model.Position;
|
||||||
Color = new Color(model.Color);
|
Color = new Color(model.Color);
|
||||||
Permissions = new GuildPermissions(model.Permissions);
|
Permissions = new GuildPermissions(model.Permissions);
|
||||||
|
Flags = model.Flags;
|
||||||
|
|
||||||
if (model.Tags.IsSpecified)
|
if (model.Tags.IsSpecified)
|
||||||
Tags = model.Tags.Value.ToEntity();
|
Tags = model.Tags.Value.ToEntity();
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,9 @@ namespace Discord.WebSocket
|
|||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public RoleTags Tags { get; private set; }
|
public RoleTags Tags { get; private set; }
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public RoleFlags Flags { get; private set; }
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
|
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -82,6 +85,8 @@ namespace Discord.WebSocket
|
|||||||
Position = model.Position;
|
Position = model.Position;
|
||||||
Color = new Color(model.Color);
|
Color = new Color(model.Color);
|
||||||
Permissions = new GuildPermissions(model.Permissions);
|
Permissions = new GuildPermissions(model.Permissions);
|
||||||
|
Flags = model.Flags;
|
||||||
|
|
||||||
if (model.Tags.IsSpecified)
|
if (model.Tags.IsSpecified)
|
||||||
Tags = model.Tags.Value.ToEntity();
|
Tags = model.Tags.Value.ToEntity();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user