feat: consumable entitlements (#10235)

* feat: consumable entitlements

* feat: move logic to EntitlementManager

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Almeida
2024-05-01 18:57:25 +01:00
committed by GitHub
parent a1aeaeb9d8
commit 997887069a
5 changed files with 50 additions and 0 deletions

View File

@@ -77,4 +77,20 @@ export class MonetizationAPI {
) {
await this.rest.delete(Routes.entitlement(applicationId, entitlementId), { signal });
}
/**
* Marks a given entitlement for the user as consumed. Only available for One-Time Purchase consumable SKUs.
*
* @see {@link https://discord.com/developers/docs/monetization/entitlements#consume-an-entitlement}
* @param applicationId - The application id to consume the entitlement for
* @param entitlementId - The entitlement id to consume
* @param options - The options for consuming the entitlement
*/
public async consumeEntitlement(
applicationId: Snowflake,
entitlementId: Snowflake,
{ signal }: Pick<RequestData, 'signal'> = {},
) {
await this.rest.post(Routes.consumeEntitlement(applicationId, entitlementId), { signal });
}
}