mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 09:20:08 +00:00
feat(types,rest,bot): Document new entitlement endpoint behavior (#4021)
* Add getEntitlement endpoint * use camelCase for excludeDeleted
This commit is contained in:
@@ -749,6 +749,9 @@ export function createBotHelpers<TProps extends TransformersDesiredProperties, T
|
||||
listEntitlements: async (applicationId, options) => {
|
||||
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<TBot['transformers']['$inferredTypes']['guildOnboarding']>
|
||||
listEntitlements: (applicationId: BigString, options?: GetEntitlements) => Promise<TBot['transformers']['$inferredTypes']['entitlement'][]>
|
||||
getEntitlement: (applicationId: BigString, entitlementId: BigString) => Promise<TBot['transformers']['$inferredTypes']['entitlement']>
|
||||
createTestEntitlement: (
|
||||
applicationId: BigString,
|
||||
body: CreateEntitlement,
|
||||
|
||||
@@ -1632,6 +1632,10 @@ export function createRestManager(options: CreateRestManagerOptions): RestManage
|
||||
return await rest.get<DiscordEntitlement[]>(rest.routes.monetization.entitlements(applicationId, options))
|
||||
},
|
||||
|
||||
async getEntitlement(applicationId, entitlementId) {
|
||||
return await rest.get<DiscordEntitlement>(rest.routes.monetization.entitlement(applicationId, entitlementId))
|
||||
},
|
||||
|
||||
async deleteTestEntitlement(applicationId, entitlementId) {
|
||||
await rest.delete(rest.routes.monetization.entitlement(applicationId, entitlementId))
|
||||
},
|
||||
|
||||
@@ -2995,6 +2995,13 @@ export interface RestManager {
|
||||
* @param {GetEntitlements} [options] - The optional query params for the endpoint
|
||||
*/
|
||||
listEntitlements: (applicationId: BigString, options?: GetEntitlements) => Promise<Camelize<DiscordEntitlement>[]>
|
||||
/**
|
||||
* 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<Camelize<DiscordEntitlement>>
|
||||
/**
|
||||
* 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<void>
|
||||
/**
|
||||
* 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<void>
|
||||
/**
|
||||
|
||||
@@ -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 */
|
||||
|
||||
Reference in New Issue
Block a user