more cringe (#2919)
This commit is contained in:
@@ -1,7 +1,45 @@
|
|||||||
namespace Discord;
|
namespace Discord;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the type of entitlement.
|
||||||
|
/// </summary>
|
||||||
public enum EntitlementType
|
public enum EntitlementType
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The entitlement was purchased by user.
|
||||||
|
/// </summary>
|
||||||
|
Purchase = 1,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Entitlement for Discord Nitro subscription.
|
||||||
|
/// </summary>
|
||||||
|
PremiumSubscription = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Entitlement was gifted by developer.
|
||||||
|
/// </summary>
|
||||||
|
DeveloperGift = 3,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Entitlement was purchased by a dev in application test mode.
|
||||||
|
/// </summary>
|
||||||
|
TestModePurchase = 4,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Entitlement was granted when the SKU was free.
|
||||||
|
/// </summary>
|
||||||
|
FreePurchase = 5,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Entitlement was gifted by another user.
|
||||||
|
/// </summary>
|
||||||
|
UserGift = 6,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Entitlement was claimed by user for free as a Nitro Subscriber.
|
||||||
|
/// </summary>
|
||||||
|
PremiumPurchase = 7,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The entitlement was purchased as an app subscription.
|
/// The entitlement was purchased as an app subscription.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -2,10 +2,19 @@ using System;
|
|||||||
|
|
||||||
namespace Discord;
|
namespace Discord;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// SKU flags for subscriptions.
|
||||||
|
/// </summary>
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum SKUFlags
|
public enum SKUFlags
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The SKU is a guild subscription.
|
||||||
|
/// </summary>
|
||||||
GuildSubscription = 1 << 7,
|
GuildSubscription = 1 << 7,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The SKU is a user subscription.
|
||||||
|
/// </summary>
|
||||||
UserSubscription = 1 << 8
|
UserSubscription = 1 << 8
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,13 +2,23 @@ namespace Discord;
|
|||||||
|
|
||||||
public enum SKUType
|
public enum SKUType
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Durable one-time purchase.
|
||||||
|
/// </summary>
|
||||||
|
Durable = 2,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Consumable one-time purchase.
|
||||||
|
/// </summary>
|
||||||
|
Consumable = 3,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a recurring subscription.
|
/// Represents a recurring subscription.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Subscription = 5,
|
Subscription = 5,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// System-generated group for each <see cref="SKUType.Subscription"/> SKU created.
|
/// System-generated group for each <see cref="Subscription"/> SKU created.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
SubscriptionGroup = 6,
|
SubscriptionGroup = 6,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -349,5 +349,12 @@ namespace Discord
|
|||||||
/// Returns all SKUs for a given application.
|
/// Returns all SKUs for a given application.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task<IReadOnlyCollection<SKU>> GetSKUsAsync(RequestOptions options = null);
|
Task<IReadOnlyCollection<SKU>> GetSKUsAsync(RequestOptions options = null);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Marks a given one-time purchase entitlement for the user as consumed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entitlementId">The id of the entitlement.</param>
|
||||||
|
/// <param name="options">The options to be used when sending the request.</param>
|
||||||
|
Task ConsumeEntitlementAsync(ulong entitlementId, RequestOptions options = null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ internal class Entitlement
|
|||||||
public EntitlementType Type { get; set; }
|
public EntitlementType Type { get; set; }
|
||||||
|
|
||||||
[JsonProperty("consumed")]
|
[JsonProperty("consumed")]
|
||||||
public bool IsConsumed { get; set; }
|
public Optional<bool> IsConsumed { get; set; }
|
||||||
|
|
||||||
[JsonProperty("starts_at")]
|
[JsonProperty("starts_at")]
|
||||||
public Optional<DateTimeOffset> StartsAt { get; set; }
|
public Optional<DateTimeOffset> StartsAt { get; set; }
|
||||||
|
|||||||
@@ -292,6 +292,11 @@ namespace Discord.Rest
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
Task<IReadOnlyCollection<SKU>> IDiscordClient.GetSKUsAsync(RequestOptions options) => Task.FromResult<IReadOnlyCollection<SKU>>(Array.Empty<SKU>());
|
Task<IReadOnlyCollection<SKU>> IDiscordClient.GetSKUsAsync(RequestOptions options) => Task.FromResult<IReadOnlyCollection<SKU>>(Array.Empty<SKU>());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Marks a given one-time purchase entitlement for the user as consumed.
|
||||||
|
/// </summary>
|
||||||
|
Task IDiscordClient.ConsumeEntitlementAsync(ulong entitlementId, RequestOptions options) => Task.CompletedTask;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -446,6 +446,9 @@ namespace Discord.Rest
|
|||||||
return models.Select(x => new SKU(x.Id, x.Type, x.ApplicationId, x.Name, x.Slug)).ToImmutableArray();
|
return models.Select(x => new SKU(x.Id, x.Type, x.ApplicationId, x.Name, x.Slug)).ToImmutableArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Task ConsumeEntitlementAsync(BaseDiscordClient client, ulong entitlementId, RequestOptions options = null)
|
||||||
|
=> client.ApiClient.ConsumeEntitlementAsync(entitlementId, options);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2828,6 +2828,9 @@ namespace Discord.API
|
|||||||
public Task<SKU[]> ListSKUsAsync(RequestOptions options = null)
|
public Task<SKU[]> ListSKUsAsync(RequestOptions options = null)
|
||||||
=> SendAsync<SKU[]>("GET", () => $"applications/{CurrentApplicationId}/skus", new BucketIds(), options: options);
|
=> SendAsync<SKU[]>("GET", () => $"applications/{CurrentApplicationId}/skus", new BucketIds(), options: options);
|
||||||
|
|
||||||
|
public Task ConsumeEntitlementAsync(ulong entitlementId, RequestOptions options = null)
|
||||||
|
=> SendAsync("POST", () => $"applications/{CurrentApplicationId}/entitlements/{entitlementId}/consume", new BucketIds(), options: options);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -296,6 +296,10 @@ namespace Discord.Rest
|
|||||||
public Task<IReadOnlyCollection<SKU>> GetSKUsAsync(RequestOptions options = null)
|
public Task<IReadOnlyCollection<SKU>> GetSKUsAsync(RequestOptions options = null)
|
||||||
=> ClientHelper.ListSKUsAsync(this, options);
|
=> ClientHelper.ListSKUsAsync(this, options);
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Task ConsumeEntitlementAsync(ulong entitlementId, RequestOptions options = null)
|
||||||
|
=> ClientHelper.ConsumeEntitlementAsync(this, entitlementId, options);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region IDiscordClient
|
#region IDiscordClient
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ public class RestEntitlement : RestEntity<ulong>, IEntitlement
|
|||||||
: null;
|
: null;
|
||||||
ApplicationId = model.ApplicationId;
|
ApplicationId = model.ApplicationId;
|
||||||
Type = model.Type;
|
Type = model.Type;
|
||||||
IsConsumed = model.IsConsumed;
|
IsConsumed = model.IsConsumed.GetValueOrDefault(false);
|
||||||
StartsAt = model.StartsAt.IsSpecified
|
StartsAt = model.StartsAt.IsSpecified
|
||||||
? model.StartsAt.Value
|
? model.StartsAt.Value
|
||||||
: null;
|
: null;
|
||||||
|
|||||||
@@ -447,6 +447,10 @@ namespace Discord.WebSocket
|
|||||||
public Task<IReadOnlyCollection<SKU>> GetSKUsAsync(RequestOptions options = null)
|
public Task<IReadOnlyCollection<SKU>> GetSKUsAsync(RequestOptions options = null)
|
||||||
=> ClientHelper.ListSKUsAsync(this, options);
|
=> ClientHelper.ListSKUsAsync(this, options);
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
public Task ConsumeEntitlementAsync(ulong entitlementId, RequestOptions options = null)
|
||||||
|
=> ClientHelper.ConsumeEntitlementAsync(this, entitlementId, options);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets entitlements from cache.
|
/// Gets entitlements from cache.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class SocketEntitlement : SocketEntity<ulong>, IEntitlement
|
|||||||
|
|
||||||
ApplicationId = model.ApplicationId;
|
ApplicationId = model.ApplicationId;
|
||||||
Type = model.Type;
|
Type = model.Type;
|
||||||
IsConsumed = model.IsConsumed;
|
IsConsumed = model.IsConsumed.GetValueOrDefault(false);
|
||||||
StartsAt = model.StartsAt.IsSpecified
|
StartsAt = model.StartsAt.IsSpecified
|
||||||
? model.StartsAt.Value
|
? model.StartsAt.Value
|
||||||
: null;
|
: null;
|
||||||
|
|||||||
Reference in New Issue
Block a user