From ba080619170b484f671011abe3b0a61c0e69cca9 Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Sun, 22 Oct 2023 21:02:01 +0200 Subject: [PATCH] feat: premium app subscriptions (#833) Co-authored-by: Vlad Frangu Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Almeida --- deno/gateway/v10.ts | 56 ++++++++- deno/gateway/v9.ts | 56 ++++++++- deno/payloads/v10/_interactions/base.ts | 5 + deno/payloads/v10/_interactions/responses.ts | 11 +- deno/payloads/v10/mod.ts | 1 + deno/payloads/v10/monetization.ts | 115 +++++++++++++++++++ deno/payloads/v9/_interactions/base.ts | 5 + deno/payloads/v9/_interactions/responses.ts | 11 +- deno/payloads/v9/mod.ts | 1 + deno/payloads/v9/monetization.ts | 115 +++++++++++++++++++ deno/rest/v10/mod.ts | 23 ++++ deno/rest/v10/monetization.ts | 85 ++++++++++++++ deno/rest/v9/mod.ts | 23 ++++ deno/rest/v9/monetization.ts | 85 ++++++++++++++ gateway/v10.ts | 56 ++++++++- gateway/v9.ts | 56 ++++++++- payloads/v10/_interactions/base.ts | 5 + payloads/v10/_interactions/responses.ts | 11 +- payloads/v10/index.ts | 1 + payloads/v10/monetization.ts | 115 +++++++++++++++++++ payloads/v9/_interactions/base.ts | 5 + payloads/v9/_interactions/responses.ts | 11 +- payloads/v9/index.ts | 1 + payloads/v9/monetization.ts | 115 +++++++++++++++++++ rest/v10/index.ts | 23 ++++ rest/v10/monetization.ts | 85 ++++++++++++++ rest/v9/index.ts | 23 ++++ rest/v9/monetization.ts | 85 ++++++++++++++ 28 files changed, 1176 insertions(+), 8 deletions(-) create mode 100644 deno/payloads/v10/monetization.ts create mode 100644 deno/payloads/v9/monetization.ts create mode 100644 deno/rest/v10/monetization.ts create mode 100644 deno/rest/v9/monetization.ts create mode 100644 payloads/v10/monetization.ts create mode 100644 payloads/v9/monetization.ts create mode 100644 rest/v10/monetization.ts create mode 100644 rest/v9/monetization.ts diff --git a/deno/gateway/v10.ts b/deno/gateway/v10.ts index a0d0f8f25..e30c673d3 100644 --- a/deno/gateway/v10.ts +++ b/deno/gateway/v10.ts @@ -33,6 +33,7 @@ import type { PresenceUpdateStatus, AutoModerationRuleTriggerType, APIAuditLogEntry, + APIEntitlement, } from '../payloads/v10/mod.ts'; import type { Nullable } from '../utils/internals.ts'; @@ -268,6 +269,9 @@ export enum GatewayDispatchEvents { AutoModerationRuleDelete = 'AUTO_MODERATION_RULE_DELETE', AutoModerationActionExecution = 'AUTO_MODERATION_ACTION_EXECUTION', GuildAuditLogEntryCreate = 'GUILD_AUDIT_LOG_ENTRY_CREATE', + EntitlementCreate = 'ENTITLEMENT_CREATE', + EntitlementUpdate = 'ENTITLEMENT_UPDATE', + EntitlementDelete = 'ENTITLEMENT_DELETE', } export type GatewaySendPayload = @@ -341,7 +345,8 @@ export type GatewayDispatchPayload = | GatewayVoiceServerUpdateDispatch | GatewayVoiceStateUpdateDispatch | GatewayWebhooksUpdateDispatch - | GatewayGuildAuditLogEntryCreateDispatch; + | GatewayGuildAuditLogEntryCreateDispatch + | GatewayEntitlementModifyDispatch; // #region Dispatch Payloads @@ -672,6 +677,55 @@ export interface GatewayChannelPinsUpdateDispatchData { last_pin_timestamp?: string | null; } +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementModifyDispatchData = APIEntitlement; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementModifyDispatch = DataPayload< + | GatewayDispatchEvents.EntitlementCreate + | GatewayDispatchEvents.EntitlementUpdate + | GatewayDispatchEvents.EntitlementDelete, + GatewayEntitlementModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + */ +export type GatewayEntitlementCreateDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + */ +export type GatewayEntitlementCreateDispatch = GatewayEntitlementModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + */ +export type GatewayEntitlementUpdateDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + */ +export type GatewayEntitlementUpdateDispatch = GatewayEntitlementModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementDeleteDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementDeleteDispatch = GatewayEntitlementModifyDispatch; + /** * https://discord.com/developers/docs/topics/gateway-events#guild-create */ diff --git a/deno/gateway/v9.ts b/deno/gateway/v9.ts index 7a1ca63e0..b24173f95 100644 --- a/deno/gateway/v9.ts +++ b/deno/gateway/v9.ts @@ -35,6 +35,7 @@ import type { APIAuditLogEntry, } from '../payloads/v9/mod.ts'; import type { Nullable } from '../utils/internals.ts'; +import type { APIEntitlement } from '../v10.ts'; export * from './common.ts'; @@ -267,6 +268,9 @@ export enum GatewayDispatchEvents { AutoModerationRuleDelete = 'AUTO_MODERATION_RULE_DELETE', AutoModerationActionExecution = 'AUTO_MODERATION_ACTION_EXECUTION', GuildAuditLogEntryCreate = 'GUILD_AUDIT_LOG_ENTRY_CREATE', + EntitlementCreate = 'ENTITLEMENT_CREATE', + EntitlementUpdate = 'ENTITLEMENT_UPDATE', + EntitlementDelete = 'ENTITLEMENT_DELETE', } export type GatewaySendPayload = @@ -340,7 +344,8 @@ export type GatewayDispatchPayload = | GatewayVoiceServerUpdateDispatch | GatewayVoiceStateUpdateDispatch | GatewayWebhooksUpdateDispatch - | GatewayGuildAuditLogEntryCreateDispatch; + | GatewayGuildAuditLogEntryCreateDispatch + | GatewayEntitlementModifyDispatch; // #region Dispatch Payloads @@ -671,6 +676,55 @@ export interface GatewayChannelPinsUpdateDispatchData { last_pin_timestamp?: string | null; } +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementModifyDispatchData = APIEntitlement; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementModifyDispatch = DataPayload< + | GatewayDispatchEvents.EntitlementCreate + | GatewayDispatchEvents.EntitlementUpdate + | GatewayDispatchEvents.EntitlementDelete, + GatewayEntitlementModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + */ +export type GatewayEntitlementCreateDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + */ +export type GatewayEntitlementCreateDispatch = GatewayEntitlementModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + */ +export type GatewayEntitlementUpdateDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + */ +export type GatewayEntitlementUpdateDispatch = GatewayEntitlementModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementDeleteDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementDeleteDispatch = GatewayEntitlementModifyDispatch; + /** * https://discord.com/developers/docs/topics/gateway-events#guild-update */ diff --git a/deno/payloads/v10/_interactions/base.ts b/deno/payloads/v10/_interactions/base.ts index 1b044a4c6..b50f3d384 100644 --- a/deno/payloads/v10/_interactions/base.ts +++ b/deno/payloads/v10/_interactions/base.ts @@ -10,6 +10,7 @@ import type { ThreadChannelType, } from '../channel.ts'; import type { APIGuildMember } from '../guild.ts'; +import type { APIEntitlement } from '../monetization.ts'; import type { APIUser } from '../user.ts'; import type { InteractionType } from './responses.ts'; @@ -130,6 +131,10 @@ export interface APIBaseInteraction { * The guild's preferred locale, if invoked in a guild */ guild_locale?: LocaleString; + /** + * For monetized apps, any entitlements for the invoking user, representing access to premium SKUs + */ + entitlements: APIEntitlement[]; } export type APIDMInteractionWrapper> = Omit< diff --git a/deno/payloads/v10/_interactions/responses.ts b/deno/payloads/v10/_interactions/responses.ts index 7601f96cf..bd0f7bc39 100644 --- a/deno/payloads/v10/_interactions/responses.ts +++ b/deno/payloads/v10/_interactions/responses.ts @@ -24,7 +24,8 @@ export type APIInteractionResponse = | APIInteractionResponseDeferredMessageUpdate | APIInteractionResponseUpdateMessage | APIApplicationCommandAutocompleteResponse - | APIModalInteractionResponse; + | APIModalInteractionResponse + | APIPremiumRequiredInteractionResponse; export interface APIInteractionResponsePong { type: InteractionResponseType.Pong; @@ -40,6 +41,10 @@ export interface APIModalInteractionResponse { data: APIModalInteractionResponseCallbackData; } +export interface APIPremiumRequiredInteractionResponse { + type: InteractionResponseType.PremiumRequired; +} + export interface APIInteractionResponseChannelMessageWithSource { type: InteractionResponseType.ChannelMessageWithSource; data: APIInteractionResponseCallbackData; @@ -91,6 +96,10 @@ export enum InteractionResponseType { * Respond to an interaction with an modal for a user to fill-out */ Modal, + /** + * Respond to an interaction with an upgrade button, only available for apps with monetization enabled + */ + PremiumRequired, } /** diff --git a/deno/payloads/v10/mod.ts b/deno/payloads/v10/mod.ts index 9143395b3..06f590de5 100644 --- a/deno/payloads/v10/mod.ts +++ b/deno/payloads/v10/mod.ts @@ -18,3 +18,4 @@ export * from './template.ts'; export * from './user.ts'; export * from './voice.ts'; export * from './webhook.ts'; +export * from './monetization.ts'; diff --git a/deno/payloads/v10/monetization.ts b/deno/payloads/v10/monetization.ts new file mode 100644 index 000000000..7b06e504d --- /dev/null +++ b/deno/payloads/v10/monetization.ts @@ -0,0 +1,115 @@ +import type { Snowflake } from '../../globals.ts'; + +/** + * https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-structure + */ +export interface APIEntitlement { + /** + * ID of the entitlement + */ + id: Snowflake; + /** + * ID of the SKU + */ + sku_id: Snowflake; + /** + * ID of the user that is granted access to the entitlement's sku + */ + user_id?: Snowflake; + /** + * ID of the guild that is granted access to the entitlement's sku + */ + guild_id?: Snowflake; + /** + * ID of the parent application + */ + application_id: Snowflake; + /** + * Type of entitlement + */ + type: EntitlementType; + /** + * Whether the entitlement was deleted + */ + deleted: boolean; + /** + * Start date at which the entitlement is valid. Not present when using test entitlements. + */ + starts_at?: string; + /** + * Date at which the entitlement is no longer valid. Not present when using test entitlements. + */ + ends_at?: string; +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-types + */ +export enum EntitlementType { + /** + * Entitlement was purchased as an app subscription + */ + ApplicationSubscription = 8, +} + +/** + * https://discord.com/developers/docs/monetization/skus#sku-object-sku-structure + */ +export interface APISKU { + /** + * ID of SKU + */ + id: Snowflake; + /** + * Type of SKU + */ + type: SKUType; + /** + * ID of the parent application + */ + application_id: Snowflake; + /** + * Customer-facing name of your premium offering + */ + name: string; + /** + * System-generated URL slug based on the SKU's name + */ + slug: string; + /** + * SKU flags combined as a bitfield + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + flags: SKUFlags; +} + +/** + * https://discord.com/developers/docs/monetization/skus#sku-object-sku-flags + */ +export enum SKUFlags { + /** + * SKU is available for purchase + */ + Available = 1 << 2, + /** + * Recurring SKU that can be purchased by a user and applied to a single server. + * Grants access to every user in that server. + */ + GuildSubscription = 1 << 7, + /** + * Recurring SKU purchased by a user for themselves. Grants access to the purchasing user in every server. + */ + UserSubscription = 1 << 8, +} + +export enum SKUType { + /** + * Represents a recurring subscription + */ + Subscription = 5, + /** + * System-generated group for each Subscription SKU created + */ + SubscriptionGroup = 6, +} diff --git a/deno/payloads/v9/_interactions/base.ts b/deno/payloads/v9/_interactions/base.ts index 5e8f4356c..8afb0971f 100644 --- a/deno/payloads/v9/_interactions/base.ts +++ b/deno/payloads/v9/_interactions/base.ts @@ -10,6 +10,7 @@ import type { ThreadChannelType, } from '../channel.ts'; import type { APIGuildMember } from '../guild.ts'; +import type { APIEntitlement } from '../monetization.ts'; import type { APIUser } from '../user.ts'; import type { InteractionType } from './responses.ts'; @@ -130,6 +131,10 @@ export interface APIBaseInteraction { * The guild's preferred locale, if invoked in a guild */ guild_locale?: LocaleString; + /** + * For monetized apps, any entitlements for the invoking user, representing access to premium SKUs + */ + entitlements: APIEntitlement[]; } export type APIDMInteractionWrapper> = Omit< diff --git a/deno/payloads/v9/_interactions/responses.ts b/deno/payloads/v9/_interactions/responses.ts index 8d09967e5..6bb3966dd 100644 --- a/deno/payloads/v9/_interactions/responses.ts +++ b/deno/payloads/v9/_interactions/responses.ts @@ -24,7 +24,8 @@ export type APIInteractionResponse = | APIInteractionResponseDeferredMessageUpdate | APIInteractionResponseUpdateMessage | APIApplicationCommandAutocompleteResponse - | APIModalInteractionResponse; + | APIModalInteractionResponse + | APIPremiumRequiredInteractionResponse; export interface APIInteractionResponsePong { type: InteractionResponseType.Pong; @@ -40,6 +41,10 @@ export interface APIModalInteractionResponse { data: APIModalInteractionResponseCallbackData; } +export interface APIPremiumRequiredInteractionResponse { + type: InteractionResponseType.PremiumRequired; +} + export interface APIInteractionResponseChannelMessageWithSource { type: InteractionResponseType.ChannelMessageWithSource; data: APIInteractionResponseCallbackData; @@ -91,6 +96,10 @@ export enum InteractionResponseType { * Respond to an interaction with an modal for a user to fill-out */ Modal, + /** + * Respond to an interaction with an upgrade button, only available for apps with monetization enabled + */ + PremiumRequired, } /** diff --git a/deno/payloads/v9/mod.ts b/deno/payloads/v9/mod.ts index 9143395b3..06f590de5 100644 --- a/deno/payloads/v9/mod.ts +++ b/deno/payloads/v9/mod.ts @@ -18,3 +18,4 @@ export * from './template.ts'; export * from './user.ts'; export * from './voice.ts'; export * from './webhook.ts'; +export * from './monetization.ts'; diff --git a/deno/payloads/v9/monetization.ts b/deno/payloads/v9/monetization.ts new file mode 100644 index 000000000..7b06e504d --- /dev/null +++ b/deno/payloads/v9/monetization.ts @@ -0,0 +1,115 @@ +import type { Snowflake } from '../../globals.ts'; + +/** + * https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-structure + */ +export interface APIEntitlement { + /** + * ID of the entitlement + */ + id: Snowflake; + /** + * ID of the SKU + */ + sku_id: Snowflake; + /** + * ID of the user that is granted access to the entitlement's sku + */ + user_id?: Snowflake; + /** + * ID of the guild that is granted access to the entitlement's sku + */ + guild_id?: Snowflake; + /** + * ID of the parent application + */ + application_id: Snowflake; + /** + * Type of entitlement + */ + type: EntitlementType; + /** + * Whether the entitlement was deleted + */ + deleted: boolean; + /** + * Start date at which the entitlement is valid. Not present when using test entitlements. + */ + starts_at?: string; + /** + * Date at which the entitlement is no longer valid. Not present when using test entitlements. + */ + ends_at?: string; +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-types + */ +export enum EntitlementType { + /** + * Entitlement was purchased as an app subscription + */ + ApplicationSubscription = 8, +} + +/** + * https://discord.com/developers/docs/monetization/skus#sku-object-sku-structure + */ +export interface APISKU { + /** + * ID of SKU + */ + id: Snowflake; + /** + * Type of SKU + */ + type: SKUType; + /** + * ID of the parent application + */ + application_id: Snowflake; + /** + * Customer-facing name of your premium offering + */ + name: string; + /** + * System-generated URL slug based on the SKU's name + */ + slug: string; + /** + * SKU flags combined as a bitfield + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + flags: SKUFlags; +} + +/** + * https://discord.com/developers/docs/monetization/skus#sku-object-sku-flags + */ +export enum SKUFlags { + /** + * SKU is available for purchase + */ + Available = 1 << 2, + /** + * Recurring SKU that can be purchased by a user and applied to a single server. + * Grants access to every user in that server. + */ + GuildSubscription = 1 << 7, + /** + * Recurring SKU purchased by a user for themselves. Grants access to the purchasing user in every server. + */ + UserSubscription = 1 << 8, +} + +export enum SKUType { + /** + * Represents a recurring subscription + */ + Subscription = 5, + /** + * System-generated group for each Subscription SKU created + */ + SubscriptionGroup = 6, +} diff --git a/deno/rest/v10/mod.ts b/deno/rest/v10/mod.ts index 95f75faea..9da646bf8 100644 --- a/deno/rest/v10/mod.ts +++ b/deno/rest/v10/mod.ts @@ -18,6 +18,7 @@ export * from './template.ts'; export * from './user.ts'; export * from './voice.ts'; export * from './webhook.ts'; +export * from './monetization.ts'; export const APIVersion = '10'; @@ -907,6 +908,28 @@ export const Routes = { currentApplication() { return '/applications/@me' as const; }, + /** + * Route for: + * - GET `/applications/{application.id}/entitlements` + * - POST `/applications/{application.id}/entitlements` + */ + entitlements(applicationId: Snowflake) { + return `/applications/${applicationId}/entitlements` as const; + }, + /** + * Route for: + * - DELETE `/applications/{application.id}/entitlements/{entitlement.id}` + */ + entitlement(applicationId: Snowflake, entitlementId: Snowflake) { + return `/applications/${applicationId}/entitlements/${entitlementId}` as const; + }, + /** + * Route for: + * - GET `/applications/{application.id}/skus` + */ + skus(applicationId: Snowflake) { + return `/applications/${applicationId}/skus` as const; + }, }; export const StickerPackApplicationId = '710982414301790216'; diff --git a/deno/rest/v10/monetization.ts b/deno/rest/v10/monetization.ts new file mode 100644 index 000000000..dd40f9f0a --- /dev/null +++ b/deno/rest/v10/monetization.ts @@ -0,0 +1,85 @@ +import type { Snowflake } from '../../globals.ts'; +import type { APIEntitlement, APISKU } from '../../v10.ts'; + +/** + * https://discord.com/developers/docs/monetization/entitlements#list-entitlements + */ +export interface RESTGetAPIEntitlementsQuery { + /** + * User ID to look up entitlements for + */ + user_id?: Snowflake | undefined; + /** + * Optional list of SKU IDs to check entitlements for + * Comma-delimited set of snowflakes + */ + sku_ids?: string | undefined; + /** + * Retrieve entitlements before this entitlement ID + */ + before?: Snowflake | undefined; + /** + * Retrieve entitlements after this entitlement ID + */ + after?: Snowflake | undefined; + /** + * Number of entitlements to return (1-100) + * + * @default 100 + */ + limit?: number | undefined; + /** + * Guild ID to look up entitlements for + */ + guild_id?: Snowflake | undefined; + /** + * Whether ended entitlements should be omitted + */ + exclude_ended?: boolean | undefined; +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#list-entitlements + */ +export type RESTGetAPIEntitlementsResult = APIEntitlement[]; + +/** + * https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement + */ +export interface RESTPostAPIEntitlementBody { + /** + * ID of the SKU to grant the entitlement to + */ + sku_id: Snowflake; + /** + * ID of the guild or user to grant the entitlement to + */ + owner_id: Snowflake; + /** + * The type of entitlement owner + */ + owner_type: EntitlementOwnerType; +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement + */ +export type RESTPostAPIEntitlementResult = Partial>; + +/** + * https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement + */ +export enum EntitlementOwnerType { + Guild = 1, + User, +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#delete-test-entitlement + */ +export type RESTDeleteAPIEntitlementResult = never; + +/** + * https://discord.com/developers/docs/monetization/skus#list-skus + */ +export type RESTGetAPISKUsResult = APISKU[]; diff --git a/deno/rest/v9/mod.ts b/deno/rest/v9/mod.ts index 944cc456a..0995b93d0 100644 --- a/deno/rest/v9/mod.ts +++ b/deno/rest/v9/mod.ts @@ -18,6 +18,7 @@ export * from './template.ts'; export * from './user.ts'; export * from './voice.ts'; export * from './webhook.ts'; +export * from './monetization.ts'; export const APIVersion = '9'; @@ -916,6 +917,28 @@ export const Routes = { currentApplication() { return '/applications/@me' as const; }, + /** + * Route for: + * - GET `/applications/{application.id}/entitlements` + * - POST `/applications/{application.id}/entitlements` + */ + entitlements(applicationId: Snowflake) { + return `/applications/${applicationId}/entitlements` as const; + }, + /** + * Route for: + * - DELETE `/applications/{application.id}/entitlements/{entitlement.id}` + */ + entitlement(applicationId: Snowflake, entitlementId: Snowflake) { + return `/applications/${applicationId}/entitlements/${entitlementId}` as const; + }, + /** + * Route for: + * - GET `/applications/{application.id}/skus` + */ + skus(applicationId: Snowflake) { + return `/applications/${applicationId}/skus` as const; + }, }; export const StickerPackApplicationId = '710982414301790216'; diff --git a/deno/rest/v9/monetization.ts b/deno/rest/v9/monetization.ts new file mode 100644 index 000000000..dd40f9f0a --- /dev/null +++ b/deno/rest/v9/monetization.ts @@ -0,0 +1,85 @@ +import type { Snowflake } from '../../globals.ts'; +import type { APIEntitlement, APISKU } from '../../v10.ts'; + +/** + * https://discord.com/developers/docs/monetization/entitlements#list-entitlements + */ +export interface RESTGetAPIEntitlementsQuery { + /** + * User ID to look up entitlements for + */ + user_id?: Snowflake | undefined; + /** + * Optional list of SKU IDs to check entitlements for + * Comma-delimited set of snowflakes + */ + sku_ids?: string | undefined; + /** + * Retrieve entitlements before this entitlement ID + */ + before?: Snowflake | undefined; + /** + * Retrieve entitlements after this entitlement ID + */ + after?: Snowflake | undefined; + /** + * Number of entitlements to return (1-100) + * + * @default 100 + */ + limit?: number | undefined; + /** + * Guild ID to look up entitlements for + */ + guild_id?: Snowflake | undefined; + /** + * Whether ended entitlements should be omitted + */ + exclude_ended?: boolean | undefined; +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#list-entitlements + */ +export type RESTGetAPIEntitlementsResult = APIEntitlement[]; + +/** + * https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement + */ +export interface RESTPostAPIEntitlementBody { + /** + * ID of the SKU to grant the entitlement to + */ + sku_id: Snowflake; + /** + * ID of the guild or user to grant the entitlement to + */ + owner_id: Snowflake; + /** + * The type of entitlement owner + */ + owner_type: EntitlementOwnerType; +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement + */ +export type RESTPostAPIEntitlementResult = Partial>; + +/** + * https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement + */ +export enum EntitlementOwnerType { + Guild = 1, + User, +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#delete-test-entitlement + */ +export type RESTDeleteAPIEntitlementResult = never; + +/** + * https://discord.com/developers/docs/monetization/skus#list-skus + */ +export type RESTGetAPISKUsResult = APISKU[]; diff --git a/gateway/v10.ts b/gateway/v10.ts index 181588c97..b8a8e0351 100644 --- a/gateway/v10.ts +++ b/gateway/v10.ts @@ -33,6 +33,7 @@ import type { PresenceUpdateStatus, AutoModerationRuleTriggerType, APIAuditLogEntry, + APIEntitlement, } from '../payloads/v10/index'; import type { Nullable } from '../utils/internals'; @@ -268,6 +269,9 @@ export enum GatewayDispatchEvents { AutoModerationRuleDelete = 'AUTO_MODERATION_RULE_DELETE', AutoModerationActionExecution = 'AUTO_MODERATION_ACTION_EXECUTION', GuildAuditLogEntryCreate = 'GUILD_AUDIT_LOG_ENTRY_CREATE', + EntitlementCreate = 'ENTITLEMENT_CREATE', + EntitlementUpdate = 'ENTITLEMENT_UPDATE', + EntitlementDelete = 'ENTITLEMENT_DELETE', } export type GatewaySendPayload = @@ -341,7 +345,8 @@ export type GatewayDispatchPayload = | GatewayVoiceServerUpdateDispatch | GatewayVoiceStateUpdateDispatch | GatewayWebhooksUpdateDispatch - | GatewayGuildAuditLogEntryCreateDispatch; + | GatewayGuildAuditLogEntryCreateDispatch + | GatewayEntitlementModifyDispatch; // #region Dispatch Payloads @@ -672,6 +677,55 @@ export interface GatewayChannelPinsUpdateDispatchData { last_pin_timestamp?: string | null; } +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementModifyDispatchData = APIEntitlement; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementModifyDispatch = DataPayload< + | GatewayDispatchEvents.EntitlementCreate + | GatewayDispatchEvents.EntitlementUpdate + | GatewayDispatchEvents.EntitlementDelete, + GatewayEntitlementModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + */ +export type GatewayEntitlementCreateDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + */ +export type GatewayEntitlementCreateDispatch = GatewayEntitlementModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + */ +export type GatewayEntitlementUpdateDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + */ +export type GatewayEntitlementUpdateDispatch = GatewayEntitlementModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementDeleteDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementDeleteDispatch = GatewayEntitlementModifyDispatch; + /** * https://discord.com/developers/docs/topics/gateway-events#guild-create */ diff --git a/gateway/v9.ts b/gateway/v9.ts index 2e9f6b40b..85986bef8 100644 --- a/gateway/v9.ts +++ b/gateway/v9.ts @@ -35,6 +35,7 @@ import type { APIAuditLogEntry, } from '../payloads/v9/index'; import type { Nullable } from '../utils/internals'; +import type { APIEntitlement } from '../v10'; export * from './common'; @@ -267,6 +268,9 @@ export enum GatewayDispatchEvents { AutoModerationRuleDelete = 'AUTO_MODERATION_RULE_DELETE', AutoModerationActionExecution = 'AUTO_MODERATION_ACTION_EXECUTION', GuildAuditLogEntryCreate = 'GUILD_AUDIT_LOG_ENTRY_CREATE', + EntitlementCreate = 'ENTITLEMENT_CREATE', + EntitlementUpdate = 'ENTITLEMENT_UPDATE', + EntitlementDelete = 'ENTITLEMENT_DELETE', } export type GatewaySendPayload = @@ -340,7 +344,8 @@ export type GatewayDispatchPayload = | GatewayVoiceServerUpdateDispatch | GatewayVoiceStateUpdateDispatch | GatewayWebhooksUpdateDispatch - | GatewayGuildAuditLogEntryCreateDispatch; + | GatewayGuildAuditLogEntryCreateDispatch + | GatewayEntitlementModifyDispatch; // #region Dispatch Payloads @@ -671,6 +676,55 @@ export interface GatewayChannelPinsUpdateDispatchData { last_pin_timestamp?: string | null; } +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementModifyDispatchData = APIEntitlement; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementModifyDispatch = DataPayload< + | GatewayDispatchEvents.EntitlementCreate + | GatewayDispatchEvents.EntitlementUpdate + | GatewayDispatchEvents.EntitlementDelete, + GatewayEntitlementModifyDispatchData +>; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + */ +export type GatewayEntitlementCreateDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-create + */ +export type GatewayEntitlementCreateDispatch = GatewayEntitlementModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + */ +export type GatewayEntitlementUpdateDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-update + */ +export type GatewayEntitlementUpdateDispatch = GatewayEntitlementModifyDispatch; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementDeleteDispatchData = GatewayEntitlementModifyDispatchData; + +/** + * https://discord.com/developers/docs/topics/gateway-events#entitlement-delete + */ +export type GatewayEntitlementDeleteDispatch = GatewayEntitlementModifyDispatch; + /** * https://discord.com/developers/docs/topics/gateway-events#guild-update */ diff --git a/payloads/v10/_interactions/base.ts b/payloads/v10/_interactions/base.ts index e2bde4fd8..fde9962cd 100644 --- a/payloads/v10/_interactions/base.ts +++ b/payloads/v10/_interactions/base.ts @@ -10,6 +10,7 @@ import type { ThreadChannelType, } from '../channel'; import type { APIGuildMember } from '../guild'; +import type { APIEntitlement } from '../monetization'; import type { APIUser } from '../user'; import type { InteractionType } from './responses'; @@ -130,6 +131,10 @@ export interface APIBaseInteraction { * The guild's preferred locale, if invoked in a guild */ guild_locale?: LocaleString; + /** + * For monetized apps, any entitlements for the invoking user, representing access to premium SKUs + */ + entitlements: APIEntitlement[]; } export type APIDMInteractionWrapper> = Omit< diff --git a/payloads/v10/_interactions/responses.ts b/payloads/v10/_interactions/responses.ts index bb757d940..fb34dc14c 100644 --- a/payloads/v10/_interactions/responses.ts +++ b/payloads/v10/_interactions/responses.ts @@ -24,7 +24,8 @@ export type APIInteractionResponse = | APIInteractionResponseDeferredMessageUpdate | APIInteractionResponseUpdateMessage | APIApplicationCommandAutocompleteResponse - | APIModalInteractionResponse; + | APIModalInteractionResponse + | APIPremiumRequiredInteractionResponse; export interface APIInteractionResponsePong { type: InteractionResponseType.Pong; @@ -40,6 +41,10 @@ export interface APIModalInteractionResponse { data: APIModalInteractionResponseCallbackData; } +export interface APIPremiumRequiredInteractionResponse { + type: InteractionResponseType.PremiumRequired; +} + export interface APIInteractionResponseChannelMessageWithSource { type: InteractionResponseType.ChannelMessageWithSource; data: APIInteractionResponseCallbackData; @@ -91,6 +96,10 @@ export enum InteractionResponseType { * Respond to an interaction with an modal for a user to fill-out */ Modal, + /** + * Respond to an interaction with an upgrade button, only available for apps with monetization enabled + */ + PremiumRequired, } /** diff --git a/payloads/v10/index.ts b/payloads/v10/index.ts index b83fd0968..0a13eeeb4 100644 --- a/payloads/v10/index.ts +++ b/payloads/v10/index.ts @@ -18,3 +18,4 @@ export * from './template'; export * from './user'; export * from './voice'; export * from './webhook'; +export * from './monetization'; diff --git a/payloads/v10/monetization.ts b/payloads/v10/monetization.ts new file mode 100644 index 000000000..38e6902fc --- /dev/null +++ b/payloads/v10/monetization.ts @@ -0,0 +1,115 @@ +import type { Snowflake } from '../../globals'; + +/** + * https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-structure + */ +export interface APIEntitlement { + /** + * ID of the entitlement + */ + id: Snowflake; + /** + * ID of the SKU + */ + sku_id: Snowflake; + /** + * ID of the user that is granted access to the entitlement's sku + */ + user_id?: Snowflake; + /** + * ID of the guild that is granted access to the entitlement's sku + */ + guild_id?: Snowflake; + /** + * ID of the parent application + */ + application_id: Snowflake; + /** + * Type of entitlement + */ + type: EntitlementType; + /** + * Whether the entitlement was deleted + */ + deleted: boolean; + /** + * Start date at which the entitlement is valid. Not present when using test entitlements. + */ + starts_at?: string; + /** + * Date at which the entitlement is no longer valid. Not present when using test entitlements. + */ + ends_at?: string; +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-types + */ +export enum EntitlementType { + /** + * Entitlement was purchased as an app subscription + */ + ApplicationSubscription = 8, +} + +/** + * https://discord.com/developers/docs/monetization/skus#sku-object-sku-structure + */ +export interface APISKU { + /** + * ID of SKU + */ + id: Snowflake; + /** + * Type of SKU + */ + type: SKUType; + /** + * ID of the parent application + */ + application_id: Snowflake; + /** + * Customer-facing name of your premium offering + */ + name: string; + /** + * System-generated URL slug based on the SKU's name + */ + slug: string; + /** + * SKU flags combined as a bitfield + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + flags: SKUFlags; +} + +/** + * https://discord.com/developers/docs/monetization/skus#sku-object-sku-flags + */ +export enum SKUFlags { + /** + * SKU is available for purchase + */ + Available = 1 << 2, + /** + * Recurring SKU that can be purchased by a user and applied to a single server. + * Grants access to every user in that server. + */ + GuildSubscription = 1 << 7, + /** + * Recurring SKU purchased by a user for themselves. Grants access to the purchasing user in every server. + */ + UserSubscription = 1 << 8, +} + +export enum SKUType { + /** + * Represents a recurring subscription + */ + Subscription = 5, + /** + * System-generated group for each Subscription SKU created + */ + SubscriptionGroup = 6, +} diff --git a/payloads/v9/_interactions/base.ts b/payloads/v9/_interactions/base.ts index 70ed64106..1f96b5646 100644 --- a/payloads/v9/_interactions/base.ts +++ b/payloads/v9/_interactions/base.ts @@ -10,6 +10,7 @@ import type { ThreadChannelType, } from '../channel'; import type { APIGuildMember } from '../guild'; +import type { APIEntitlement } from '../monetization'; import type { APIUser } from '../user'; import type { InteractionType } from './responses'; @@ -130,6 +131,10 @@ export interface APIBaseInteraction { * The guild's preferred locale, if invoked in a guild */ guild_locale?: LocaleString; + /** + * For monetized apps, any entitlements for the invoking user, representing access to premium SKUs + */ + entitlements: APIEntitlement[]; } export type APIDMInteractionWrapper> = Omit< diff --git a/payloads/v9/_interactions/responses.ts b/payloads/v9/_interactions/responses.ts index b4a9351fd..65fe01d4d 100644 --- a/payloads/v9/_interactions/responses.ts +++ b/payloads/v9/_interactions/responses.ts @@ -24,7 +24,8 @@ export type APIInteractionResponse = | APIInteractionResponseDeferredMessageUpdate | APIInteractionResponseUpdateMessage | APIApplicationCommandAutocompleteResponse - | APIModalInteractionResponse; + | APIModalInteractionResponse + | APIPremiumRequiredInteractionResponse; export interface APIInteractionResponsePong { type: InteractionResponseType.Pong; @@ -40,6 +41,10 @@ export interface APIModalInteractionResponse { data: APIModalInteractionResponseCallbackData; } +export interface APIPremiumRequiredInteractionResponse { + type: InteractionResponseType.PremiumRequired; +} + export interface APIInteractionResponseChannelMessageWithSource { type: InteractionResponseType.ChannelMessageWithSource; data: APIInteractionResponseCallbackData; @@ -91,6 +96,10 @@ export enum InteractionResponseType { * Respond to an interaction with an modal for a user to fill-out */ Modal, + /** + * Respond to an interaction with an upgrade button, only available for apps with monetization enabled + */ + PremiumRequired, } /** diff --git a/payloads/v9/index.ts b/payloads/v9/index.ts index b83fd0968..0a13eeeb4 100644 --- a/payloads/v9/index.ts +++ b/payloads/v9/index.ts @@ -18,3 +18,4 @@ export * from './template'; export * from './user'; export * from './voice'; export * from './webhook'; +export * from './monetization'; diff --git a/payloads/v9/monetization.ts b/payloads/v9/monetization.ts new file mode 100644 index 000000000..38e6902fc --- /dev/null +++ b/payloads/v9/monetization.ts @@ -0,0 +1,115 @@ +import type { Snowflake } from '../../globals'; + +/** + * https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-structure + */ +export interface APIEntitlement { + /** + * ID of the entitlement + */ + id: Snowflake; + /** + * ID of the SKU + */ + sku_id: Snowflake; + /** + * ID of the user that is granted access to the entitlement's sku + */ + user_id?: Snowflake; + /** + * ID of the guild that is granted access to the entitlement's sku + */ + guild_id?: Snowflake; + /** + * ID of the parent application + */ + application_id: Snowflake; + /** + * Type of entitlement + */ + type: EntitlementType; + /** + * Whether the entitlement was deleted + */ + deleted: boolean; + /** + * Start date at which the entitlement is valid. Not present when using test entitlements. + */ + starts_at?: string; + /** + * Date at which the entitlement is no longer valid. Not present when using test entitlements. + */ + ends_at?: string; +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-types + */ +export enum EntitlementType { + /** + * Entitlement was purchased as an app subscription + */ + ApplicationSubscription = 8, +} + +/** + * https://discord.com/developers/docs/monetization/skus#sku-object-sku-structure + */ +export interface APISKU { + /** + * ID of SKU + */ + id: Snowflake; + /** + * Type of SKU + */ + type: SKUType; + /** + * ID of the parent application + */ + application_id: Snowflake; + /** + * Customer-facing name of your premium offering + */ + name: string; + /** + * System-generated URL slug based on the SKU's name + */ + slug: string; + /** + * SKU flags combined as a bitfield + * + * See https://en.wikipedia.org/wiki/Bit_field + */ + flags: SKUFlags; +} + +/** + * https://discord.com/developers/docs/monetization/skus#sku-object-sku-flags + */ +export enum SKUFlags { + /** + * SKU is available for purchase + */ + Available = 1 << 2, + /** + * Recurring SKU that can be purchased by a user and applied to a single server. + * Grants access to every user in that server. + */ + GuildSubscription = 1 << 7, + /** + * Recurring SKU purchased by a user for themselves. Grants access to the purchasing user in every server. + */ + UserSubscription = 1 << 8, +} + +export enum SKUType { + /** + * Represents a recurring subscription + */ + Subscription = 5, + /** + * System-generated group for each Subscription SKU created + */ + SubscriptionGroup = 6, +} diff --git a/rest/v10/index.ts b/rest/v10/index.ts index ea3b7dd2a..eaf6095a3 100644 --- a/rest/v10/index.ts +++ b/rest/v10/index.ts @@ -18,6 +18,7 @@ export * from './template'; export * from './user'; export * from './voice'; export * from './webhook'; +export * from './monetization'; export const APIVersion = '10'; @@ -907,6 +908,28 @@ export const Routes = { currentApplication() { return '/applications/@me' as const; }, + /** + * Route for: + * - GET `/applications/{application.id}/entitlements` + * - POST `/applications/{application.id}/entitlements` + */ + entitlements(applicationId: Snowflake) { + return `/applications/${applicationId}/entitlements` as const; + }, + /** + * Route for: + * - DELETE `/applications/{application.id}/entitlements/{entitlement.id}` + */ + entitlement(applicationId: Snowflake, entitlementId: Snowflake) { + return `/applications/${applicationId}/entitlements/${entitlementId}` as const; + }, + /** + * Route for: + * - GET `/applications/{application.id}/skus` + */ + skus(applicationId: Snowflake) { + return `/applications/${applicationId}/skus` as const; + }, }; export const StickerPackApplicationId = '710982414301790216'; diff --git a/rest/v10/monetization.ts b/rest/v10/monetization.ts new file mode 100644 index 000000000..54d800a53 --- /dev/null +++ b/rest/v10/monetization.ts @@ -0,0 +1,85 @@ +import type { Snowflake } from '../../globals'; +import type { APIEntitlement, APISKU } from '../../v10'; + +/** + * https://discord.com/developers/docs/monetization/entitlements#list-entitlements + */ +export interface RESTGetAPIEntitlementsQuery { + /** + * User ID to look up entitlements for + */ + user_id?: Snowflake | undefined; + /** + * Optional list of SKU IDs to check entitlements for + * Comma-delimited set of snowflakes + */ + sku_ids?: string | undefined; + /** + * Retrieve entitlements before this entitlement ID + */ + before?: Snowflake | undefined; + /** + * Retrieve entitlements after this entitlement ID + */ + after?: Snowflake | undefined; + /** + * Number of entitlements to return (1-100) + * + * @default 100 + */ + limit?: number | undefined; + /** + * Guild ID to look up entitlements for + */ + guild_id?: Snowflake | undefined; + /** + * Whether ended entitlements should be omitted + */ + exclude_ended?: boolean | undefined; +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#list-entitlements + */ +export type RESTGetAPIEntitlementsResult = APIEntitlement[]; + +/** + * https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement + */ +export interface RESTPostAPIEntitlementBody { + /** + * ID of the SKU to grant the entitlement to + */ + sku_id: Snowflake; + /** + * ID of the guild or user to grant the entitlement to + */ + owner_id: Snowflake; + /** + * The type of entitlement owner + */ + owner_type: EntitlementOwnerType; +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement + */ +export type RESTPostAPIEntitlementResult = Partial>; + +/** + * https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement + */ +export enum EntitlementOwnerType { + Guild = 1, + User, +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#delete-test-entitlement + */ +export type RESTDeleteAPIEntitlementResult = never; + +/** + * https://discord.com/developers/docs/monetization/skus#list-skus + */ +export type RESTGetAPISKUsResult = APISKU[]; diff --git a/rest/v9/index.ts b/rest/v9/index.ts index b31ed87eb..26e857ac6 100644 --- a/rest/v9/index.ts +++ b/rest/v9/index.ts @@ -18,6 +18,7 @@ export * from './template'; export * from './user'; export * from './voice'; export * from './webhook'; +export * from './monetization'; export const APIVersion = '9'; @@ -916,6 +917,28 @@ export const Routes = { currentApplication() { return '/applications/@me' as const; }, + /** + * Route for: + * - GET `/applications/{application.id}/entitlements` + * - POST `/applications/{application.id}/entitlements` + */ + entitlements(applicationId: Snowflake) { + return `/applications/${applicationId}/entitlements` as const; + }, + /** + * Route for: + * - DELETE `/applications/{application.id}/entitlements/{entitlement.id}` + */ + entitlement(applicationId: Snowflake, entitlementId: Snowflake) { + return `/applications/${applicationId}/entitlements/${entitlementId}` as const; + }, + /** + * Route for: + * - GET `/applications/{application.id}/skus` + */ + skus(applicationId: Snowflake) { + return `/applications/${applicationId}/skus` as const; + }, }; export const StickerPackApplicationId = '710982414301790216'; diff --git a/rest/v9/monetization.ts b/rest/v9/monetization.ts new file mode 100644 index 000000000..54d800a53 --- /dev/null +++ b/rest/v9/monetization.ts @@ -0,0 +1,85 @@ +import type { Snowflake } from '../../globals'; +import type { APIEntitlement, APISKU } from '../../v10'; + +/** + * https://discord.com/developers/docs/monetization/entitlements#list-entitlements + */ +export interface RESTGetAPIEntitlementsQuery { + /** + * User ID to look up entitlements for + */ + user_id?: Snowflake | undefined; + /** + * Optional list of SKU IDs to check entitlements for + * Comma-delimited set of snowflakes + */ + sku_ids?: string | undefined; + /** + * Retrieve entitlements before this entitlement ID + */ + before?: Snowflake | undefined; + /** + * Retrieve entitlements after this entitlement ID + */ + after?: Snowflake | undefined; + /** + * Number of entitlements to return (1-100) + * + * @default 100 + */ + limit?: number | undefined; + /** + * Guild ID to look up entitlements for + */ + guild_id?: Snowflake | undefined; + /** + * Whether ended entitlements should be omitted + */ + exclude_ended?: boolean | undefined; +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#list-entitlements + */ +export type RESTGetAPIEntitlementsResult = APIEntitlement[]; + +/** + * https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement + */ +export interface RESTPostAPIEntitlementBody { + /** + * ID of the SKU to grant the entitlement to + */ + sku_id: Snowflake; + /** + * ID of the guild or user to grant the entitlement to + */ + owner_id: Snowflake; + /** + * The type of entitlement owner + */ + owner_type: EntitlementOwnerType; +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement + */ +export type RESTPostAPIEntitlementResult = Partial>; + +/** + * https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement + */ +export enum EntitlementOwnerType { + Guild = 1, + User, +} + +/** + * https://discord.com/developers/docs/monetization/entitlements#delete-test-entitlement + */ +export type RESTDeleteAPIEntitlementResult = never; + +/** + * https://discord.com/developers/docs/monetization/skus#list-skus + */ +export type RESTGetAPISKUsResult = APISKU[];