this object is fucked but at least its not missing props now (#2956)

This commit is contained in:
Mihail Gribkov
2024-07-04 00:00:49 +03:00
committed by GitHub
parent ae497945b4
commit 6b691b1ad2
3 changed files with 79 additions and 47 deletions

View File

@@ -1,10 +1,10 @@
namespace Discord namespace Discord;
/// <summary>
/// Provides tags related to a discord role.
/// </summary>
public class RoleTags
{ {
/// <summary>
/// Provides tags related to a discord role.
/// </summary>
public class RoleTags
{
/// <summary> /// <summary>
/// Gets the identifier of the bot that this role belongs to, if it does. /// Gets the identifier of the bot that this role belongs to, if it does.
/// </summary> /// </summary>
@@ -13,6 +13,7 @@ namespace Discord
/// <see langword="null"/>. /// <see langword="null"/>.
/// </returns> /// </returns>
public ulong? BotId { get; } public ulong? BotId { get; }
/// <summary> /// <summary>
/// Gets the identifier of the integration that this role belongs to, if it does. /// Gets the identifier of the integration that this role belongs to, if it does.
/// </summary> /// </summary>
@@ -21,6 +22,7 @@ namespace Discord
/// <see langword="null"/>. /// <see langword="null"/>.
/// </returns> /// </returns>
public ulong? IntegrationId { get; } public ulong? IntegrationId { get; }
/// <summary> /// <summary>
/// Gets if this role is the guild's premium subscriber (booster) role. /// Gets if this role is the guild's premium subscriber (booster) role.
/// </summary> /// </summary>
@@ -30,11 +32,28 @@ namespace Discord
/// </returns> /// </returns>
public bool IsPremiumSubscriberRole { get; } public bool IsPremiumSubscriberRole { get; }
internal RoleTags(ulong? botId, ulong? integrationId, bool isPremiumSubscriber) /// <summary>
/// Gets the identifier of the subscription listing that this role belongs to, if it does.
/// </summary>
public ulong? SubscriptionListingId { get; }
/// <summary>
/// Gets whether this role is available for purchase.
/// </summary>
public bool IsAvailableForPurchase { get; }
/// <summary>
/// Gets whether this role is a guild's linked role.
/// </summary>
public bool IsGuildConnection { get; }
internal RoleTags(ulong? botId, ulong? integrationId, bool isPremiumSubscriber, ulong? subscriptionListingId, bool isAvailableForPurchase, bool isGuildConnection)
{ {
BotId = botId; BotId = botId;
IntegrationId = integrationId; IntegrationId = integrationId;
IsPremiumSubscriberRole = isPremiumSubscriber; IsPremiumSubscriberRole = isPremiumSubscriber;
} SubscriptionListingId = subscriptionListingId;
IsAvailableForPurchase = isAvailableForPurchase;
IsGuildConnection = isGuildConnection;
} }
} }

View File

@@ -1,14 +1,24 @@
using Newtonsoft.Json; using Newtonsoft.Json;
namespace Discord.API namespace Discord.API;
internal class RoleTags
{ {
internal class RoleTags
{
[JsonProperty("bot_id")] [JsonProperty("bot_id")]
public Optional<ulong> BotId { get; set; } public Optional<ulong> BotId { get; set; }
[JsonProperty("integration_id")] [JsonProperty("integration_id")]
public Optional<ulong> IntegrationId { get; set; } public Optional<ulong> IntegrationId { get; set; }
[JsonProperty("premium_subscriber")] [JsonProperty("premium_subscriber")]
public Optional<bool?> IsPremiumSubscriber { get; set; } public Optional<bool?> IsPremiumSubscriber { get; set; }
}
[JsonProperty("subscription_listing_id")]
public Optional<ulong> SubscriptionListingId { get; set; }
[JsonProperty("available_for_purchase")]
public Optional<bool?> IsAvailableForPurchase { get; set; }
[JsonProperty("guild_connections")]
public Optional<bool?> GuildConnections { get; set; }
} }

View File

@@ -38,9 +38,12 @@ namespace Discord.Rest
public static RoleTags ToEntity(this API.RoleTags model) public static RoleTags ToEntity(this API.RoleTags model)
{ {
return new RoleTags( return new RoleTags(
model.BotId.IsSpecified ? model.BotId.Value : null, model.BotId.ToNullable(),
model.IntegrationId.IsSpecified ? model.IntegrationId.Value : null, model.IntegrationId.ToNullable(),
model.IsPremiumSubscriber.IsSpecified); model.IsPremiumSubscriber.IsSpecified,
model.SubscriptionListingId.ToNullable(),
model.IsAvailableForPurchase.IsSpecified,
model.GuildConnections.IsSpecified);
} }
public static API.Embed ToModel(this Embed entity) public static API.Embed ToModel(this Embed entity)
{ {