mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-19 21:13:30 +01:00
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:
3
packages/discord.js/typings/index.d.ts
vendored
3
packages/discord.js/typings/index.d.ts
vendored
@@ -1346,12 +1346,14 @@ export class Entitlement extends Base {
|
||||
public guildId: Snowflake | null;
|
||||
public applicationId: Snowflake;
|
||||
public type: EntitlementType;
|
||||
public consumed: boolean;
|
||||
public deleted: boolean;
|
||||
public startsTimestamp: number | null;
|
||||
public endsTimestamp: number | null;
|
||||
public get guild(): Guild | null;
|
||||
public get startsAt(): Date | null;
|
||||
public get endsAt(): Date | null;
|
||||
public consume(): Promise<void>;
|
||||
public fetchUser(): Promise<User>;
|
||||
public isActive(): boolean;
|
||||
public isTest(): this is this & {
|
||||
@@ -4179,6 +4181,7 @@ export class EntitlementManager extends CachedManager<Snowflake, Entitlement, En
|
||||
public fetch(options?: FetchEntitlementsOptions): Promise<Collection<Snowflake, Entitlement>>;
|
||||
public createTest(options: GuildEntitlementCreateOptions | UserEntitlementCreateOptions): Promise<Entitlement>;
|
||||
public deleteTest(entitlement: EntitlementResolvable): Promise<void>;
|
||||
public consume(entitlementId: Snowflake): Promise<void>;
|
||||
}
|
||||
|
||||
export interface FetchGuildApplicationCommandFetchOptions extends Omit<FetchApplicationCommandOptions, 'guildId'> {}
|
||||
|
||||
@@ -2495,6 +2495,8 @@ declare const sku: SKU;
|
||||
|
||||
await application.entitlements.deleteTest(entitlement);
|
||||
|
||||
await application.entitlements.consume(snowflake);
|
||||
|
||||
expectType<boolean>(entitlement.isActive());
|
||||
|
||||
if (entitlement.isUserSubscription()) {
|
||||
|
||||
Reference in New Issue
Block a user