feature: Add role tags (#1721)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
#pragma warning disable CS1591
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API
|
||||
@@ -21,5 +21,7 @@ namespace Discord.API
|
||||
public ulong Permissions { get; set; }
|
||||
[JsonProperty("managed")]
|
||||
public bool Managed { get; set; }
|
||||
[JsonProperty("tags")]
|
||||
public Optional<RoleTags> Tags { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
15
src/Discord.Net.Rest/API/Common/RoleTags.cs
Normal file
15
src/Discord.Net.Rest/API/Common/RoleTags.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma warning disable CS1591
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Discord.API
|
||||
{
|
||||
internal class RoleTags
|
||||
{
|
||||
[JsonProperty("bot_id")]
|
||||
public Optional<ulong> BotId { get; set; }
|
||||
[JsonProperty("integration_id")]
|
||||
public Optional<ulong> IntegrationId { get; set; }
|
||||
[JsonProperty("premium_subscriber")]
|
||||
public Optional<bool?> IsPremiumSubscriber { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,8 @@ namespace Discord.Rest
|
||||
public GuildPermissions Permissions { get; private set; }
|
||||
/// <inheritdoc />
|
||||
public int Position { get; private set; }
|
||||
/// <inheritdoc />
|
||||
public RoleTags Tags { get; private set; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public DateTimeOffset CreatedAt => SnowflakeUtils.FromSnowflake(Id);
|
||||
@@ -56,6 +58,8 @@ namespace Discord.Rest
|
||||
Position = model.Position;
|
||||
Color = new Color(model.Color);
|
||||
Permissions = new GuildPermissions(model.Permissions);
|
||||
if (model.Tags.IsSpecified)
|
||||
Tags = model.Tags.Value.ToEntity();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -34,6 +34,13 @@ namespace Discord.Rest
|
||||
model.Thumbnail.IsSpecified ? model.Thumbnail.Value.ToEntity() : (EmbedThumbnail?)null,
|
||||
model.Fields.IsSpecified ? model.Fields.Value.Select(x => x.ToEntity()).ToImmutableArray() : ImmutableArray.Create<EmbedField>());
|
||||
}
|
||||
public static RoleTags ToEntity(this API.RoleTags model)
|
||||
{
|
||||
return new RoleTags(
|
||||
model.BotId.IsSpecified ? model.BotId.Value : null,
|
||||
model.IntegrationId.IsSpecified ? model.IntegrationId.Value : null,
|
||||
model.IsPremiumSubscriber.IsSpecified ? true : false);
|
||||
}
|
||||
public static API.Embed ToModel(this Embed entity)
|
||||
{
|
||||
if (entity == null) return null;
|
||||
|
||||
Reference in New Issue
Block a user