/
monetization.ts
155 lines (150 loc) · 3.08 KB
/
monetization.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
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;
/**
* For consumable items, whether or not the entitlement has been consumed
*/
consumed?: boolean;
}
/**
* https://discord.com/developers/docs/monetization/entitlements#entitlement-object-entitlement-types
*/
export enum EntitlementType {
/**
* Entitlement was purchased by user
*/
Purchase = 1,
/**
* Entitlement for Discord Nitro subscription
*/
PremiumSubscription,
/**
* Entitlement was gifted by developer
*/
DeveloperGift,
/**
* Entitlement was purchased by a dev in application test mode
*/
TestModePurchase,
/**
* Entitlement was granted when the SKU was free
*/
FreePurchase,
/**
* Entitlement was gifted by another user
*/
UserGift,
/**
* Entitlement was claimed by user for free as a Nitro Subscriber
*/
PremiumPurchase,
/**
* Entitlement was purchased as an app subscription
*/
ApplicationSubscription,
}
/**
* 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 {
/**
* Durable one-time purchase
*/
Durable = 2,
/**
* Consumable one-time purchase
*/
Consumable = 3,
/**
* Represents a recurring subscription
*/
Subscription = 5,
/**
* System-generated group for each Subscription SKU created
*/
SubscriptionGroup = 6,
}