Skip to content

Commit

Permalink
this object is fucked but at least its not missing props now (#2956)
Browse files Browse the repository at this point in the history
  • Loading branch information
Misha-133 authored Jul 3, 2024
1 parent ae49794 commit 6b691b1
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 47 deletions.
87 changes: 53 additions & 34 deletions src/Discord.Net.Core/Entities/Roles/RoleTags.cs
Original file line number Diff line number Diff line change
@@ -1,40 +1,59 @@
namespace Discord
namespace Discord;

/// <summary>
/// Provides tags related to a discord role.
/// </summary>
public class RoleTags
{
/// <summary>
/// Provides tags related to a discord role.
/// Gets the identifier of the bot that this role belongs to, if it does.
/// </summary>
public class RoleTags
{
/// <summary>
/// Gets the identifier of the bot that this role belongs to, if it does.
/// </summary>
/// <returns>
/// A <see langword="ulong"/> if this role belongs to a bot; otherwise
/// <see langword="null"/>.
/// </returns>
public ulong? BotId { get; }
/// <summary>
/// Gets the identifier of the integration that this role belongs to, if it does.
/// </summary>
/// <returns>
/// A <see langword="ulong"/> if this role belongs to an integration; otherwise
/// <see langword="null"/>.
/// </returns>
public ulong? IntegrationId { get; }
/// <summary>
/// Gets if this role is the guild's premium subscriber (booster) role.
/// </summary>
/// <returns>
/// <see langword="true"/> if this role is the guild's premium subscriber role;
/// otherwise <see langword="false"/>.
/// </returns>
public bool IsPremiumSubscriberRole { get; }
/// <returns>
/// A <see langword="ulong"/> if this role belongs to a bot; otherwise
/// <see langword="null"/>.
/// </returns>
public ulong? BotId { get; }

/// <summary>
/// Gets the identifier of the integration that this role belongs to, if it does.
/// </summary>
/// <returns>
/// A <see langword="ulong"/> if this role belongs to an integration; otherwise
/// <see langword="null"/>.
/// </returns>
public ulong? IntegrationId { get; }

/// <summary>
/// Gets if this role is the guild's premium subscriber (booster) role.
/// </summary>
/// <returns>
/// <see langword="true"/> if this role is the guild's premium subscriber role;
/// otherwise <see langword="false"/>.
/// </returns>
public bool IsPremiumSubscriberRole { get; }

/// <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; }

internal RoleTags(ulong? botId, ulong? integrationId, bool isPremiumSubscriber)
{
BotId = botId;
IntegrationId = integrationId;
IsPremiumSubscriberRole = isPremiumSubscriber;
}
/// <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;
IntegrationId = integrationId;
IsPremiumSubscriberRole = isPremiumSubscriber;
SubscriptionListingId = subscriptionListingId;
IsAvailableForPurchase = isAvailableForPurchase;
IsGuildConnection = isGuildConnection;
}
}
30 changes: 20 additions & 10 deletions src/Discord.Net.Rest/API/Common/RoleTags.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
using Newtonsoft.Json;

namespace Discord.API
namespace Discord.API;

internal class RoleTags
{
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; }
}
[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; }

[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; }
}
9 changes: 6 additions & 3 deletions src/Discord.Net.Rest/Extensions/EntityExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,12 @@ public static Embed ToEntity(this API.Embed model)
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);
model.BotId.ToNullable(),
model.IntegrationId.ToNullable(),
model.IsPremiumSubscriber.IsSpecified,
model.SubscriptionListingId.ToNullable(),
model.IsAvailableForPurchase.IsSpecified,
model.GuildConnections.IsSpecified);
}
public static API.Embed ToModel(this Embed entity)
{
Expand Down

0 comments on commit 6b691b1

Please sign in to comment.