diff --git a/packages/bot/src/helpers.ts b/packages/bot/src/helpers.ts index 35f15b10e..9a25c5112 100644 --- a/packages/bot/src/helpers.ts +++ b/packages/bot/src/helpers.ts @@ -749,6 +749,9 @@ export function createBotHelpers { return (await bot.rest.listEntitlements(applicationId, options)).map((entitlement) => bot.transformers.entitlement(bot, snakelize(entitlement))) }, + getEntitlement: async (applicationId, entitlementId) => { + return bot.transformers.entitlement(bot, snakelize(await bot.rest.getEntitlement(applicationId, entitlementId))) + }, createTestEntitlement: async (applicationId, body) => { // @ts-expect-error createTestEntitlement gives a partial, and this method returns a partial return bot.transformers.entitlement(bot, snakelize(await bot.rest.createTestEntitlement(applicationId, body))) as Partial< @@ -1125,6 +1128,7 @@ export interface BotHelpers< reason?: string, ) => Promise listEntitlements: (applicationId: BigString, options?: GetEntitlements) => Promise + getEntitlement: (applicationId: BigString, entitlementId: BigString) => Promise createTestEntitlement: ( applicationId: BigString, body: CreateEntitlement, diff --git a/packages/rest/src/manager.ts b/packages/rest/src/manager.ts index 360fc5183..929c03df7 100644 --- a/packages/rest/src/manager.ts +++ b/packages/rest/src/manager.ts @@ -1632,6 +1632,10 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage return await rest.get(rest.routes.monetization.entitlements(applicationId, options)) }, + async getEntitlement(applicationId, entitlementId) { + return await rest.get(rest.routes.monetization.entitlement(applicationId, entitlementId)) + }, + async deleteTestEntitlement(applicationId, entitlementId) { await rest.delete(rest.routes.monetization.entitlement(applicationId, entitlementId)) }, diff --git a/packages/rest/src/types.ts b/packages/rest/src/types.ts index 28acaea0a..a23c1f6b2 100644 --- a/packages/rest/src/types.ts +++ b/packages/rest/src/types.ts @@ -2995,6 +2995,13 @@ export interface RestManager { * @param {GetEntitlements} [options] - The optional query params for the endpoint */ listEntitlements: (applicationId: BigString, options?: GetEntitlements) => Promise[]> + /** + * Returns an entitlement. + * + * @param applicationId - The id of the application to get the entitlement + * @param entitlementId - The id of the entitlement to get + */ + getEntitlement: (applicationId: BigString, entitlementId: BigString) => Promise> /** * Creates a test entitlement to a given SKU for a given guild or user. Discord will act as though that user or guild has entitlement to your premium offering. * @@ -3014,7 +3021,10 @@ export interface RestManager { */ deleteTestEntitlement: (applicationId: BigString, entitlementId: BigString) => Promise /** - * For One-Time Purchase consumable SKUs, marks a given entitlement for the user as consumed. The entitlement will have `consumed: true` when using {@link RestManager.listEntitlements | List Entitlements} + * For One-Time Purchase consumable SKUs, marks a given entitlement for the user as consumed. The entitlement will have `consumed: true` when using {@link listEntitlements | List Entitlements} + * + * @param applicationId - The id of the application to get the entitlement + * @param entitlementId - The id of the entitlement to get */ consumeEntitlement: (applicationId: BigString, entitlementId: BigString) => Promise /** diff --git a/packages/types/src/discordeno.ts b/packages/types/src/discordeno.ts index f15d81d2a..17e372ee1 100644 --- a/packages/types/src/discordeno.ts +++ b/packages/types/src/discordeno.ts @@ -1483,8 +1483,10 @@ export interface GetEntitlements { limit?: number /** Guild ID to look up entitlements for */ guildId?: BigString - /** Whether or not ended entitlements should be omitted */ + /** Whether or not ended entitlements should be omitted. Defaults to false, ended entitlements are included by default. */ excludeEnded?: boolean + /** Whether or not deleted entitlements should be omitted. Defaults to true, deleted entitlements are not included by default. */ + excludeDeleted?: boolean } /** https://discord.com/developers/docs/monetization/entitlements#create-test-entitlement-json-params */