dfx 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DiscordREST/types.js +6 -0
- package/DiscordREST/types.js.map +1 -0
- package/DiscordWS/index.js +2 -0
- package/DiscordWS/index.js.map +1 -0
- package/README.md +3 -0
- package/WS/index.js +71 -0
- package/WS/index.js.map +1 -0
- package/discord-api-docs/index.js +1 -0
- package/mod.js.map +1 -0
- package/package.json +6 -1
- package/types.js +1563 -0
- package/types.js.map +1 -0
- package/websocket.js +11 -0
- package/websocket.js.map +1 -0
- package/.gitmodules +0 -3
- package/.prettierrc.json +0 -4
- package/discord-api-docs/.eslintrc.json +0 -10
- package/discord-api-docs/.gitattributes +0 -11
- package/discord-api-docs/.github/ISSUE_TEMPLATE/api-bug-report.yml +0 -49
- package/discord-api-docs/.github/ISSUE_TEMPLATE/config.yml +0 -20
- package/discord-api-docs/.github/ISSUE_TEMPLATE/developer-site-bug-report.yml +0 -49
- package/discord-api-docs/.github/ISSUE_TEMPLATE/message-components-bug-report.yml +0 -49
- package/discord-api-docs/.github/ISSUE_TEMPLATE/slash-command-bug-report.yml +0 -49
- package/discord-api-docs/.github/workflows/test.yaml +0 -45
- package/discord-api-docs/.prettierignore +0 -1
- package/discord-api-docs/.prettierrc.json +0 -15
- package/discord-api-docs/CODE_OF_CONDUCT.md +0 -75
- package/discord-api-docs/CONTRIBUTING.md +0 -16
- package/discord-api-docs/README.md +0 -35
- package/discord-api-docs/docs/Change_Log.md +0 -474
- package/discord-api-docs/docs/Intro.md +0 -48
- package/discord-api-docs/docs/Legal.md +0 -154
- package/discord-api-docs/docs/Policy.md +0 -81
- package/discord-api-docs/docs/Reference.md +0 -476
- package/discord-api-docs/docs/Store_Distribution_Agreement.md +0 -179
- package/discord-api-docs/docs/dispatch/Branches_and_Builds.md +0 -654
- package/discord-api-docs/docs/dispatch/Dispatch_and_You.md +0 -17
- package/discord-api-docs/docs/dispatch/Error_Codes.md +0 -26
- package/discord-api-docs/docs/dispatch/Field_Values.md +0 -48
- package/discord-api-docs/docs/dispatch/List_of_Commands.md +0 -315
- package/discord-api-docs/docs/game_and_server_management/Alpha_and_Beta_Testing.md +0 -52
- package/discord-api-docs/docs/game_and_server_management/How_to_Get_Your_Game_on_Discord.md +0 -110
- package/discord-api-docs/docs/game_and_server_management/Special_Channels.md +0 -38
- package/discord-api-docs/docs/game_sdk/Achievements.md +0 -405
- package/discord-api-docs/docs/game_sdk/Activities.md +0 -561
- package/discord-api-docs/docs/game_sdk/Applications.md +0 -237
- package/discord-api-docs/docs/game_sdk/Discord.md +0 -443
- package/discord-api-docs/docs/game_sdk/Discord_Voice.md +0 -289
- package/discord-api-docs/docs/game_sdk/Images.md +0 -196
- package/discord-api-docs/docs/game_sdk/Lobbies.md +0 -1639
- package/discord-api-docs/docs/game_sdk/Networking.md +0 -377
- package/discord-api-docs/docs/game_sdk/Overlay.md +0 -195
- package/discord-api-docs/docs/game_sdk/Relationships.md +0 -234
- package/discord-api-docs/docs/game_sdk/SDK_Starter_Guide.md +0 -310
- package/discord-api-docs/docs/game_sdk/Storage.md +0 -312
- package/discord-api-docs/docs/game_sdk/Store.md +0 -555
- package/discord-api-docs/docs/game_sdk/Users.md +0 -178
- package/discord-api-docs/docs/interactions/Application_Commands.md +0 -1069
- package/discord-api-docs/docs/interactions/Message_Components.md +0 -454
- package/discord-api-docs/docs/interactions/Receiving_and_Responding.md +0 -372
- package/discord-api-docs/docs/interactions/Slash_Commands.md +0 -3
- package/discord-api-docs/docs/resources/Application.md +0 -82
- package/discord-api-docs/docs/resources/Audit_Log.md +0 -223
- package/discord-api-docs/docs/resources/Channel.md +0 -1267
- package/discord-api-docs/docs/resources/Emoji.md +0 -122
- package/discord-api-docs/docs/resources/Guild.md +0 -1157
- package/discord-api-docs/docs/resources/Guild_Scheduled_Event.md +0 -273
- package/discord-api-docs/docs/resources/Guild_Template.md +0 -148
- package/discord-api-docs/docs/resources/Invite.md +0 -150
- package/discord-api-docs/docs/resources/Stage_Instance.md +0 -106
- package/discord-api-docs/docs/resources/Sticker.md +0 -164
- package/discord-api-docs/docs/resources/User.md +0 -205
- package/discord-api-docs/docs/resources/Voice.md +0 -55
- package/discord-api-docs/docs/resources/Webhook.md +0 -281
- package/discord-api-docs/docs/rich_presence/Best_Practices.md +0 -88
- package/discord-api-docs/docs/rich_presence/FAQ.md +0 -45
- package/discord-api-docs/docs/rich_presence/How_To.md +0 -302
- package/discord-api-docs/docs/rich_presence/Launch_Checklist.md +0 -46
- package/discord-api-docs/docs/topics/Certified_Devices.md +0 -200
- package/discord-api-docs/docs/topics/Community_Resources.md +0 -98
- package/discord-api-docs/docs/topics/Gateway.md +0 -1600
- package/discord-api-docs/docs/topics/OAuth2.md +0 -427
- package/discord-api-docs/docs/topics/Opcodes_and_Status_Codes.md +0 -306
- package/discord-api-docs/docs/topics/Permissions.md +0 -229
- package/discord-api-docs/docs/topics/RPC.md +0 -1597
- package/discord-api-docs/docs/topics/Rate_Limits.md +0 -126
- package/discord-api-docs/docs/topics/Teams.md +0 -80
- package/discord-api-docs/docs/topics/Threads.md +0 -163
- package/discord-api-docs/docs/topics/Voice_Connections.md +0 -282
- package/discord-api-docs/images/API_center.gif +0 -0
- package/discord-api-docs/images/ask-to-join.gif +0 -0
- package/discord-api-docs/images/available-published.png +0 -0
- package/discord-api-docs/images/button-styles.png +0 -0
- package/discord-api-docs/images/certified-device.png +0 -0
- package/discord-api-docs/images/command-with-groups-subcommands-parameters.png +0 -0
- package/discord-api-docs/images/command-with-groups-subcommands.png +0 -0
- package/discord-api-docs/images/command.png +0 -0
- package/discord-api-docs/images/cpp-files-sdk.png +0 -0
- package/discord-api-docs/images/create-store-channel.png +0 -0
- package/discord-api-docs/images/deferred-example.png +0 -0
- package/discord-api-docs/images/desktop-select.png +0 -0
- package/discord-api-docs/images/game-overlay-sdk-invite.gif +0 -0
- package/discord-api-docs/images/game-overlay-sdk-voice-settings.png +0 -0
- package/discord-api-docs/images/game-overlay-sdk-voice-widget.png +0 -0
- package/discord-api-docs/images/gift-code-creation.png +0 -0
- package/discord-api-docs/images/lib-linked-sdk.png +0 -0
- package/discord-api-docs/images/message-command.png +0 -0
- package/discord-api-docs/images/mobile-select.png +0 -0
- package/discord-api-docs/images/previous-new-server-background.png +0 -0
- package/discord-api-docs/images/rp-actionable.png +0 -0
- package/discord-api-docs/images/rp-all-fields.png +0 -0
- package/discord-api-docs/images/rp-bad-art.png +0 -0
- package/discord-api-docs/images/rp-good-art.png +0 -0
- package/discord-api-docs/images/rp-legend.png +0 -0
- package/discord-api-docs/images/rp-long-strings.png +0 -0
- package/discord-api-docs/images/rp-non-actionable.png +0 -0
- package/discord-api-docs/images/rp-not-all-fields.png +0 -0
- package/discord-api-docs/images/rp-profile-example-1.png +0 -0
- package/discord-api-docs/images/rp-profile-example-2.png +0 -0
- package/discord-api-docs/images/rp-short-strings.png +0 -0
- package/discord-api-docs/images/server-banner-example.png +0 -0
- package/discord-api-docs/images/server-banner-margin-top.png +0 -0
- package/discord-api-docs/images/sku-management.png +0 -0
- package/discord-api-docs/images/snowflake.png +0 -0
- package/discord-api-docs/images/snowflake_original_size.png +0 -0
- package/discord-api-docs/images/spectate.gif +0 -0
- package/discord-api-docs/images/team-2fa.png +0 -0
- package/discord-api-docs/images/team-make-app.png +0 -0
- package/discord-api-docs/images/team-page.png +0 -0
- package/discord-api-docs/images/transfer-app-to-team.png +0 -0
- package/discord-api-docs/images/user-command.png +0 -0
- package/discord-api-docs/package-lock.json +0 -3186
- package/discord-api-docs/package.json +0 -38
- package/discord-api-docs/tsconfig.eslint.json +0 -4
- package/discord-api-docs/tsconfig.json +0 -19
- package/tsconfig.json +0 -24
|
@@ -1,555 +0,0 @@
|
|
|
1
|
-
# Store
|
|
2
|
-
|
|
3
|
-
> info
|
|
4
|
-
> Need help with the SDK? Talk to us in the [Discord Developers Server](https://discord.gg/discord-developers)!
|
|
5
|
-
|
|
6
|
-
> danger
|
|
7
|
-
> Selling SKUs on Discord is now deprecated, and will be discontinued on March 1, 2022. [Read here for more info.](https://support-dev.discord.com/hc/en-us/articles/4414590563479)
|
|
8
|
-
|
|
9
|
-
If your game has DLC or offers in-app purchases, this manager is for you! The Store Manager allows you to fetch a users' entitlements, as well as being notified when a user is granted an entitlement from a purchase flow for your game.
|
|
10
|
-
|
|
11
|
-
## Application Test Mode
|
|
12
|
-
|
|
13
|
-
With this new Store Manager comes a new fun toggle in the Discord app itself: Application Test Mode! While in Application Test Mode, you can freely make "purchases" of SKUs tied to your application. That means you can test buying your game, buying DLC, or going through an IAP flow without any credit card charges.
|
|
14
|
-
|
|
15
|
-
> info
|
|
16
|
-
> You still need to have a valid payment method on file to "purchase" SKUs in Application Test Mode; it just won't be charged at checkout.
|
|
17
|
-
|
|
18
|
-
To enable it, first make sure you have a payment method on file in User Settings -> Billing. Then:
|
|
19
|
-
|
|
20
|
-
1. Open up the Discord app
|
|
21
|
-
2. Click on the settings cog in the bottom left corner
|
|
22
|
-
3. Go to Appearance -> allll the way at the bottom
|
|
23
|
-
4. Toggle "Developer Mode" **on** and "Application Test Mode" **on**, and enter your application ID
|
|
24
|
-
5. Exit user settings
|
|
25
|
-
|
|
26
|
-
You should now see an orange bar across the top of your screen; this means it worked! The dropdown in the orange bar will show you all the available SKUs for that application; you can select one of them to go to its store page. You can also view your Library and see all the branches of your game automagically there waiting for you!
|
|
27
|
-
|
|
28
|
-
If for some reason the "Install" button is greyed out, please check the following:
|
|
29
|
-
|
|
30
|
-
1. Do you have a `LIVE_BUILD_ID` on that branch for this SKU? Check with `dispatch branch list <application_id>`.
|
|
31
|
-
2. Do you have a price tier set for this SKU? If not, pick one!
|
|
32
|
-
|
|
33
|
-
Once those two conditions are met, you should be good to go! Entitlements "purchased" with this mode enabled can be revoked with the `DELETE /entitlements` HTTP endpoint, documented below.
|
|
34
|
-
|
|
35
|
-
## Checking DLC Entitlements
|
|
36
|
-
|
|
37
|
-
If your game has DLC, and a user has purchased that DLC, you may want to check what they should have access to when the game launches. DLC entitlements will always be returned in a `FetchEntitlements()` call, so your game can check on each startup whether or not a user should have access to a certain new zone, raid, map, etc. based on their entitlements for DLC.
|
|
38
|
-
|
|
39
|
-
## Checking Consumable Entitlements
|
|
40
|
-
|
|
41
|
-
The `Discord.SkuType.Consumable` type is used for entitlements that may be "consumed" by a game's own server infrastructure. That is to say that if you have in-app purchases like gem bundles, skins, etc., they will be a `Consumable` SKU type.
|
|
42
|
-
|
|
43
|
-
What that means is that your game is expected to "consume" these entitlements by doing something on your game server—giving the player a level, more coins, a skin, etc.—and then telling Discord that's been done by calling the `POST /entitlements/<id>/consume`, documented below. Then, Discord will mark that entitlement as `consumed` (the `consumed` field in the returned object will be set to `true`).
|
|
44
|
-
|
|
45
|
-
Entitlements to consumable SKUs are intended to signal your game's server/service/database that the user should get something in-game, and that the entitlement should be invalidated afterwards.
|
|
46
|
-
|
|
47
|
-
The same consumable SKU _can_ be purchased multiple times, but we have some safeguards in place to protect against possible abuse. If you purchase a consumable SKU, you cannot purchase a second one until the first one has been consumed; in the context of normal IAP transactions, your game will be auto-consuming entitlements as soon as they're created. If some malicious folks are somehow able to generate entitlements to your SKUs, they will not be able to consume them without your token, so you'll be safe!
|
|
48
|
-
|
|
49
|
-
Non-consumable SKUs can only be purchased once.
|
|
50
|
-
|
|
51
|
-
## Data Models
|
|
52
|
-
|
|
53
|
-
###### SKU Struct
|
|
54
|
-
|
|
55
|
-
| name | type | description |
|
|
56
|
-
| ----- | -------- | ------------------------ |
|
|
57
|
-
| Id | Int64 | the unique ID of the SKU |
|
|
58
|
-
| Type | SkuType | what sort of SKU it is |
|
|
59
|
-
| Name | string | the name of the SKU |
|
|
60
|
-
| Price | SkuPrice | the price of the SKU |
|
|
61
|
-
|
|
62
|
-
###### SkuType Enum
|
|
63
|
-
|
|
64
|
-
| name | value | description |
|
|
65
|
-
| ----------- | ----- | ---------------------------------------------- |
|
|
66
|
-
| Application | 1 | SKU is a game |
|
|
67
|
-
| DLC | 2 | SKU is a DLC |
|
|
68
|
-
| Consumable | 3 | SKU is a consumable (in-app purchase) |
|
|
69
|
-
| Bundle | 4 | SKU is a bundle (comprising the other 3 types) |
|
|
70
|
-
|
|
71
|
-
###### SkuPrice Struct
|
|
72
|
-
|
|
73
|
-
| name | type | description |
|
|
74
|
-
| -------- | ------ | --------------------------------- |
|
|
75
|
-
| Amount | UInt32 | the amount of money the SKU costs |
|
|
76
|
-
| Currency | string | the currency the amount is in |
|
|
77
|
-
|
|
78
|
-
###### Entitlement Struct
|
|
79
|
-
|
|
80
|
-
| name | type | description |
|
|
81
|
-
| ----- | --------------- | ----------------------------------------------- |
|
|
82
|
-
| Id | Int64 | the unique ID of the entitlement |
|
|
83
|
-
| Type | EntitlementType | the kind of entitlement it is |
|
|
84
|
-
| SkuId | Int64 | the ID of the SKU to which the user is entitled |
|
|
85
|
-
|
|
86
|
-
###### EntitlementType Enum
|
|
87
|
-
|
|
88
|
-
| name | value | description |
|
|
89
|
-
| ------------------- | ----- | -------------------------------------------------------------- |
|
|
90
|
-
| Purchase | 1 | entitlement was purchased |
|
|
91
|
-
| PremiumSubscription | 2 | entitlement for a Discord Nitro subscription |
|
|
92
|
-
| DeveloperGift | 3 | entitlement was gifted by a developer |
|
|
93
|
-
| TestModePurchase | 4 | entitlement was purchased by a dev in application test mode |
|
|
94
|
-
| FreePurchase | 5 | entitlement was granted when the SKU was free |
|
|
95
|
-
| UserGift | 6 | entitlement was gifted by another user |
|
|
96
|
-
| PremiumPurchase | 7 | entitlement was claimed by user for free as a Nitro Subscriber |
|
|
97
|
-
|
|
98
|
-
## FetchSkus
|
|
99
|
-
|
|
100
|
-
Fetches the list of SKUs for the connected application, readying them for iteration.
|
|
101
|
-
|
|
102
|
-
> warn
|
|
103
|
-
> Only SKUs that have a price set will be fetched. If you aren't seeing any SKUs being returned, make sure they have a price set!
|
|
104
|
-
|
|
105
|
-
Returns `Discord.Result` via callback.
|
|
106
|
-
|
|
107
|
-
###### Parameters
|
|
108
|
-
|
|
109
|
-
None
|
|
110
|
-
|
|
111
|
-
###### Example
|
|
112
|
-
|
|
113
|
-
```cs
|
|
114
|
-
storeManager.FetchSkus((result) =>
|
|
115
|
-
{
|
|
116
|
-
if (result == Discord.Result.Ok)
|
|
117
|
-
{
|
|
118
|
-
Console.WriteLine("Got skus! Now I can iterate over them!");
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
## CountSkus
|
|
124
|
-
|
|
125
|
-
Get the number of SKUs readied by `FetchSkus()`.
|
|
126
|
-
|
|
127
|
-
Returns `Int32`.
|
|
128
|
-
|
|
129
|
-
###### Parameters
|
|
130
|
-
|
|
131
|
-
None
|
|
132
|
-
|
|
133
|
-
###### Example
|
|
134
|
-
|
|
135
|
-
```cs
|
|
136
|
-
for (int i = 0; i < storeManager.CountSkus(); i++)
|
|
137
|
-
{
|
|
138
|
-
var sku = storeManager.GetSkuAt(i);
|
|
139
|
-
Console.WriteLine("Sku is {0}", sku.Name);
|
|
140
|
-
}
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
## GetSku
|
|
144
|
-
|
|
145
|
-
Gets a SKU by its ID. You must call `FetchSkus()` first before being able to access SKUs in this way.
|
|
146
|
-
|
|
147
|
-
Returns `Discord.Sku`.
|
|
148
|
-
|
|
149
|
-
###### Parameters
|
|
150
|
-
|
|
151
|
-
| name | type | description |
|
|
152
|
-
| ----- | ----- | ------------------------ |
|
|
153
|
-
| skuId | Int64 | the ID of the SKU to get |
|
|
154
|
-
|
|
155
|
-
###### Example
|
|
156
|
-
|
|
157
|
-
```cs
|
|
158
|
-
storeManager.FetchSkus((_) => {});
|
|
159
|
-
var sku = storeManager.GetSku(276467180839763999);
|
|
160
|
-
Console.WriteLine("Sku is {0}", sku.Name);
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
## GetSkuAt
|
|
164
|
-
|
|
165
|
-
Gets a SKU by index when iterating over SKUs. You must call `FetchSkus()` first before being able to access SKUs in this way.
|
|
166
|
-
|
|
167
|
-
Returns `Discord.Sku`.
|
|
168
|
-
|
|
169
|
-
###### Parameters
|
|
170
|
-
|
|
171
|
-
| name | type | description |
|
|
172
|
-
| ----- | ----- | ------------------------- |
|
|
173
|
-
| index | Int32 | the index at which to get |
|
|
174
|
-
|
|
175
|
-
###### Example
|
|
176
|
-
|
|
177
|
-
```cs
|
|
178
|
-
storeManager.FetchSkus((result) =>
|
|
179
|
-
{
|
|
180
|
-
for (int i = 0; i < storeManager.CountSkus(); i++)
|
|
181
|
-
{
|
|
182
|
-
var sku = storeManager.GetSkuAt(i);
|
|
183
|
-
Console.WriteLine("Sku is {0}", sku.Name);
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
## FetchEntitlements
|
|
189
|
-
|
|
190
|
-
Fetches a list of entitlements to which the user is entitled. Applications, DLC, and Bundles will always be returned. Consumables will be returned until they are consumed by the application via the HTTP endpoint.
|
|
191
|
-
|
|
192
|
-
Returns `Discord.Result` via callback.
|
|
193
|
-
|
|
194
|
-
###### Parameters
|
|
195
|
-
|
|
196
|
-
None
|
|
197
|
-
|
|
198
|
-
###### Example
|
|
199
|
-
|
|
200
|
-
```cs
|
|
201
|
-
storeManager.FetchEntitlements((result) =>
|
|
202
|
-
{
|
|
203
|
-
if (result == Discord.Result.Ok)
|
|
204
|
-
{
|
|
205
|
-
Console.WriteLine("Got entitlements!");
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
## CountEntitlements
|
|
211
|
-
|
|
212
|
-
Get the number of entitlements readied by `FetchEntitlements()`. You must call `FetchEntitlements()` first before being able to access SKUs in this way.
|
|
213
|
-
|
|
214
|
-
Returns `Int32`.
|
|
215
|
-
|
|
216
|
-
###### Parameters
|
|
217
|
-
|
|
218
|
-
None
|
|
219
|
-
|
|
220
|
-
###### Example
|
|
221
|
-
|
|
222
|
-
```cs
|
|
223
|
-
storeManager.FetchEntitlements((result) =>
|
|
224
|
-
{
|
|
225
|
-
for (int i = 0; i < storeManager.CountEntitlements(); i++)
|
|
226
|
-
{
|
|
227
|
-
var entitlement = storeManager.GetEntitlementAt(i);
|
|
228
|
-
Console.WriteLine("Entitlement is {0}", entitlement.Name);
|
|
229
|
-
}
|
|
230
|
-
});
|
|
231
|
-
```
|
|
232
|
-
|
|
233
|
-
## GetEntitlement
|
|
234
|
-
|
|
235
|
-
Gets an entitlement by its id. You must call `FetchEntitlements()` first before being able to access SKUs in this way.
|
|
236
|
-
|
|
237
|
-
Returns `Discord.Entitlement`.
|
|
238
|
-
|
|
239
|
-
###### Parameters
|
|
240
|
-
|
|
241
|
-
| name | type | description |
|
|
242
|
-
| ------------- | ----- | -------------------------------- |
|
|
243
|
-
| entitlementId | Int64 | the ID of the entitlement to get |
|
|
244
|
-
|
|
245
|
-
###### Example
|
|
246
|
-
|
|
247
|
-
```cs
|
|
248
|
-
storeManager.FetchEntitlements((result) =>
|
|
249
|
-
{
|
|
250
|
-
var entitlement = storeManager.GetEntitlement(276467180839763999);
|
|
251
|
-
Console.WriteLine("Entitlement is {0}", entitlement.Name);
|
|
252
|
-
});
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
## GetEntitlementAt
|
|
256
|
-
|
|
257
|
-
Gets an entitlement by index when iterating over a user's entitlements. You must call `FetchEntitlements()` first before being able to access SKUs in this way.
|
|
258
|
-
|
|
259
|
-
Returns `Discord.Entitlement`.
|
|
260
|
-
|
|
261
|
-
###### Parameters
|
|
262
|
-
|
|
263
|
-
| name | type | description |
|
|
264
|
-
| ----- | ----- | ------------------------- |
|
|
265
|
-
| index | Int32 | the index at which to get |
|
|
266
|
-
|
|
267
|
-
###### Example
|
|
268
|
-
|
|
269
|
-
```cs
|
|
270
|
-
storeManager.FetchEntitlements((result) =>
|
|
271
|
-
{
|
|
272
|
-
for (int i = 0; i < storeManager.CountEntitlements(); i++)
|
|
273
|
-
{
|
|
274
|
-
var entitlement = storeManager.GetEntitlementAt(i);
|
|
275
|
-
Console.WriteLine("Entitlement is {0}", entitlement.Name);
|
|
276
|
-
}
|
|
277
|
-
});
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
## HasSkuEntitlement
|
|
281
|
-
|
|
282
|
-
Returns whether or not the user is entitled to the given SKU ID. You must call `FetchEntitlements()` first before being able to access SKUs in this way.
|
|
283
|
-
|
|
284
|
-
Returns `bool`.
|
|
285
|
-
|
|
286
|
-
###### Parameters
|
|
287
|
-
|
|
288
|
-
| name | type | description |
|
|
289
|
-
| ----- | ----- | -------------------------- |
|
|
290
|
-
| skuId | Int64 | the ID of the SKU to check |
|
|
291
|
-
|
|
292
|
-
###### Example
|
|
293
|
-
|
|
294
|
-
```cs
|
|
295
|
-
storeManager.FetchEntitlements((result) =>
|
|
296
|
-
{
|
|
297
|
-
if (storeManager.HasSkuEntitlement(276467180839763999))
|
|
298
|
-
{
|
|
299
|
-
Console.WriteLine("User has entitlement to this SKU");
|
|
300
|
-
}
|
|
301
|
-
else
|
|
302
|
-
{
|
|
303
|
-
Console.WriteLine("How are you even running this right now...");
|
|
304
|
-
}
|
|
305
|
-
});
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
## StartPurchase
|
|
309
|
-
|
|
310
|
-
Opens the overlay to begin the in-app purchase dialogue for the given SKU ID. You must call `FetchSkus()` first before being able to access SKUs in this way. If the user has enabled the overlay for your game, a purchase modal will appear in the overlay. Otherwise, the Discord client will be auto-focused with a purchase modal.
|
|
311
|
-
|
|
312
|
-
Returns `Discord.Result` via callback.
|
|
313
|
-
|
|
314
|
-
###### Parameters
|
|
315
|
-
|
|
316
|
-
| name | type | description |
|
|
317
|
-
| ----- | ----- | ------------------------------------- |
|
|
318
|
-
| skuId | Int64 | the ID of the SKU to begin purchasing |
|
|
319
|
-
|
|
320
|
-
###### Example
|
|
321
|
-
|
|
322
|
-
```cs
|
|
323
|
-
storeManager.FetchSkus((result) =>
|
|
324
|
-
{
|
|
325
|
-
storeManager.StartPurchase(276467180839763999, (result) =>
|
|
326
|
-
{
|
|
327
|
-
if (result == Discord.Result.Ok)
|
|
328
|
-
{
|
|
329
|
-
Console.WriteLine("User is in the flow!");
|
|
330
|
-
}
|
|
331
|
-
});
|
|
332
|
-
});
|
|
333
|
-
```
|
|
334
|
-
|
|
335
|
-
## OnEntitlementCreate
|
|
336
|
-
|
|
337
|
-
Fires when the connected user receives a new entitlement, either through purchase or through a developer grant.
|
|
338
|
-
|
|
339
|
-
###### Parameters
|
|
340
|
-
|
|
341
|
-
| name | type | description |
|
|
342
|
-
| ----------- | ------------------- | ----------------------------------------- |
|
|
343
|
-
| entitlement | Discord.Entitlement | the entitlement the user has been granted |
|
|
344
|
-
|
|
345
|
-
## OnEntitlementDelete
|
|
346
|
-
|
|
347
|
-
Fires when the connected user loses an entitlement, either by expiration, revocation, or consumption in the case of consumable entitlements.
|
|
348
|
-
|
|
349
|
-
###### Parameters
|
|
350
|
-
|
|
351
|
-
| name | type | description |
|
|
352
|
-
| ----------- | ------------------- | --------------------------------- |
|
|
353
|
-
| entitlement | Discord.Entitlement | the entitlement the user has lost |
|
|
354
|
-
|
|
355
|
-
## HTTP APIs
|
|
356
|
-
|
|
357
|
-
The following are HTTP requests, and should be handled by your game server, rather than a client. They require a token for an authorization header. This token should be the "Bot token" of your application. To get this token, go to your application in the Dev Portal. In the left sidebar, click the `Bot` navigation item. You should then click the `Add Bot` button.
|
|
358
|
-
|
|
359
|
-
After that, you can copy the token on this page and use it in your HTTP requests. The format for the authorization header should be `Authorization: Bot <token>`.
|
|
360
|
-
|
|
361
|
-
Note that parameters with a `?` after the name denote optional fields. Parameters with a `?` before their type denote nullable fields.
|
|
362
|
-
|
|
363
|
-
## HTTP-Specific Data Models
|
|
364
|
-
|
|
365
|
-
###### Limited Payment Data Object
|
|
366
|
-
|
|
367
|
-
| name | type | description |
|
|
368
|
-
| ------------- | ------ | ------------------------------------ |
|
|
369
|
-
| id | string | unique ID of the payment |
|
|
370
|
-
| currency | string | the currency the payment was made in |
|
|
371
|
-
| amount | int | the amount paid |
|
|
372
|
-
| tax | int | the amount of tax |
|
|
373
|
-
| tax_inclusive | bool | whether the amount is tax-inclusive |
|
|
374
|
-
|
|
375
|
-
## Get Entitlements % GET /applications/{application.id#DOCS_GAME_SDK_SDK_STARTER_GUIDE/get-set-up}/entitlements
|
|
376
|
-
|
|
377
|
-
Gets entitlements for a given user. You can use this on your game backend to check entitlements of an arbitrary user, or perhaps in an administrative panel for your support team.
|
|
378
|
-
|
|
379
|
-
###### Query Parameters
|
|
380
|
-
|
|
381
|
-
| name | type | description |
|
|
382
|
-
| -------------- | --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
383
|
-
| user_id? | snowflake | the user id to look up entitlements for |
|
|
384
|
-
| sku_ids? | comma-delimited set of snowflakes | (optional) the list SKU ids to check entitlements for |
|
|
385
|
-
| with_payments? | bool | returns [limited payment data](#DOCS_GAME_SDK_STORE/httpspecific-data-models-limited-payment-data-object) for each entitlement |
|
|
386
|
-
| before? | snowflake | retrieve entitlements before this time |
|
|
387
|
-
| after? | snowflake | retrieve entitlements after this time |
|
|
388
|
-
| limit? | int | number of entitlements to return, 1-100, default 100 |
|
|
389
|
-
|
|
390
|
-
###### Example
|
|
391
|
-
|
|
392
|
-
```
|
|
393
|
-
curl https://discord.com/api/v6/applications/461618159171141643/entitlements?user_id=53908232506183680&sku_ids=53908232599983680&with_payments=true&limit=1 \
|
|
394
|
-
-H "Authorization: Bearer <token>" \
|
|
395
|
-
-H "Accept: application/json"
|
|
396
|
-
|
|
397
|
-
// Returns
|
|
398
|
-
|
|
399
|
-
{
|
|
400
|
-
[
|
|
401
|
-
{
|
|
402
|
-
"user_id": "53908232506183680",
|
|
403
|
-
"sku_id": "53908232599983680",
|
|
404
|
-
"application_id": "461618159171141643",
|
|
405
|
-
"id": "53908232506183999",
|
|
406
|
-
"type": 1,
|
|
407
|
-
"payment": {
|
|
408
|
-
"id": "538491076055400999",
|
|
409
|
-
"currency": "usd",
|
|
410
|
-
"amount": 999,
|
|
411
|
-
"tax": 0,
|
|
412
|
-
"tax_inclusive": false
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
]
|
|
416
|
-
}
|
|
417
|
-
```
|
|
418
|
-
|
|
419
|
-
## Get Entitlement % GET /applications/{application.id#DOCS_GAME_SDK_SDK_STARTER_GUIDE/get-set-up}/entitlements/{entitlement.id#DOCS_GAME_SDK_STORE/data-models-entitlement-struct}
|
|
420
|
-
|
|
421
|
-
Fetch an entitlement by its ID. This may be useful in confirming that a user has a given entitlement that another call or the SDK says they do.
|
|
422
|
-
|
|
423
|
-
###### Query Parameters
|
|
424
|
-
|
|
425
|
-
| name | type | description |
|
|
426
|
-
| ------------- | ---- | ------------------------------------------------------------------------------------------------------------------------------ |
|
|
427
|
-
| with_payment? | bool | returns [limited payment data](#DOCS_GAME_SDK_STORE/httpspecific-data-models-limited-payment-data-object) for each entitlement |
|
|
428
|
-
|
|
429
|
-
###### Example
|
|
430
|
-
|
|
431
|
-
```
|
|
432
|
-
curl https://discord.com/api/v6/applications/461618159171141643/entitlements/53908232506183999?with_payment=true \
|
|
433
|
-
-H "Authorization: Bearer <token>" \
|
|
434
|
-
-H "Accept: application/json"
|
|
435
|
-
|
|
436
|
-
// Returns
|
|
437
|
-
|
|
438
|
-
{
|
|
439
|
-
"user_id": "53908232506183680",
|
|
440
|
-
"sku_id": "53908232599983680",
|
|
441
|
-
"application_id": "461618159171141643",
|
|
442
|
-
"id": "53908232506183999",
|
|
443
|
-
"type": 3,
|
|
444
|
-
"payment": {
|
|
445
|
-
"id": "538491076055400999",
|
|
446
|
-
"currency": "usd",
|
|
447
|
-
"amount": 999,
|
|
448
|
-
"tax": 0,
|
|
449
|
-
"tax_inclusive": false
|
|
450
|
-
}
|
|
451
|
-
}
|
|
452
|
-
```
|
|
453
|
-
|
|
454
|
-
## Get SKUs % GET /applications/{application.id#DOCS_GAME_SDK_SDK_STARTER_GUIDE/get-set-up}/skus
|
|
455
|
-
|
|
456
|
-
Get all SKUs for an application.
|
|
457
|
-
|
|
458
|
-
###### Example
|
|
459
|
-
|
|
460
|
-
```
|
|
461
|
-
curl https://discord.com/api/v6/applications/461618159171141643/skus \
|
|
462
|
-
-H "Authorization: Bearer <token>" \
|
|
463
|
-
-H "Accept: application/json"
|
|
464
|
-
|
|
465
|
-
// Returns
|
|
466
|
-
|
|
467
|
-
{
|
|
468
|
-
[
|
|
469
|
-
{
|
|
470
|
-
"id": "53908232599983680",
|
|
471
|
-
"type": 1,
|
|
472
|
-
"dependent_sku_id": null,
|
|
473
|
-
"application_id": "461618159171141643",
|
|
474
|
-
"manifest_labels": ["461618159171111111"],
|
|
475
|
-
"name": "My Awesome Test Game",
|
|
476
|
-
"access_type": 1,
|
|
477
|
-
"features": [1, 2, 3],
|
|
478
|
-
"system_requirements": {},
|
|
479
|
-
"content_ratings": {},
|
|
480
|
-
"release_date": "1999-01-01",
|
|
481
|
-
"legal_notice": {},
|
|
482
|
-
"price_tier": 1099,
|
|
483
|
-
"price": {},
|
|
484
|
-
"premium": false,
|
|
485
|
-
"locales": ["en-US"],
|
|
486
|
-
"bundled_skus": null
|
|
487
|
-
}
|
|
488
|
-
]
|
|
489
|
-
}
|
|
490
|
-
```
|
|
491
|
-
|
|
492
|
-
## Consume SKU % POST /applications/{application.id#DOCS_GAME_SDK_SDK_STARTER_GUIDE/get-set-up}/entitlements/{entitlement.id#DOCS_GAME_SDK_STORE/data-models-entitlement-struct}/consume
|
|
493
|
-
|
|
494
|
-
Marks a given entitlement for the user as consumed, meaning it will no longer be returned in an entitlements check. **Ensure the user was granted whatever items the entitlement was for before consuming it!**
|
|
495
|
-
|
|
496
|
-
###### Example
|
|
497
|
-
|
|
498
|
-
```
|
|
499
|
-
curl -X POST https://discord.com/api/v6/applications/461618159171141643/entitlements/53908232506183999/consume \
|
|
500
|
-
-H "Authorization: Bearer <token>" \
|
|
501
|
-
-H "Accept: application/json"
|
|
502
|
-
|
|
503
|
-
// Returns 204 No Content
|
|
504
|
-
```
|
|
505
|
-
|
|
506
|
-
## Delete Test Entitlement % DELETE /applications/{application.id#DOCS_GAME_SDK_SDK_STARTER_GUIDE/get-set-up}/entitlements/{entitlement.id#DOCS_GAME_SDK_STORE/data-models-entitlement-struct}
|
|
507
|
-
|
|
508
|
-
Deletes a test entitlement for an application. You can only delete entitlements that were "purchased" in developer test mode; these are entitlements of `type == TestModePurchase`. You cannot use this route to delete arbitrary entitlements that users actually purchased.
|
|
509
|
-
|
|
510
|
-
###### Example
|
|
511
|
-
|
|
512
|
-
```
|
|
513
|
-
curl -X DELETE https://discord.com/api/v6/applications/461618159171141643/entitlements/53908232506183999 \
|
|
514
|
-
-H "Authorization: Bearer <token>" \
|
|
515
|
-
-H "Accept: application/json"
|
|
516
|
-
|
|
517
|
-
// Returns 204 No Content
|
|
518
|
-
```
|
|
519
|
-
|
|
520
|
-
## Create Purchase Discount % PUT /store/skus/{sku.id#DOCS_GAME_SDK_STORE/data-models-sku-struct}/discounts/{user.id#DOCS_RESOURCES_USER/user-object}
|
|
521
|
-
|
|
522
|
-
Creates a discount for the given user on their next purchase of the given SKU. You should call this endpoint from your backend server just before calling [StartPurchase](#DOCS_GAME_SDK_STORE/startpurchase) for the SKU you wish to discount. The user will then see a discounted price for that SKU at time of payment. The discount is automatically consumed after successful purchase or if the TTL expires.
|
|
523
|
-
|
|
524
|
-
###### Parameters
|
|
525
|
-
|
|
526
|
-
| name | type | description |
|
|
527
|
-
| ----------- | ---- | -------------------------------------------------------------------------------------- |
|
|
528
|
-
| percent_off | int | the percentage to discount - max of 100, min of 1 |
|
|
529
|
-
| ttl? | int | the time to live for the discount, in seconds - max of 3600, min of 60, default of 600 |
|
|
530
|
-
|
|
531
|
-
###### Example
|
|
532
|
-
|
|
533
|
-
```
|
|
534
|
-
curl -X PUT https://discord.com/api/v6/store/skus/461618229171141643/discounts/53908232522183999 \
|
|
535
|
-
-H "Authorization: Bearer <token>" \
|
|
536
|
-
-H "Accept: application/json" \
|
|
537
|
-
-H "Content-type: application/json" \
|
|
538
|
-
-d '{"percent_off": 10, "ttl": 600}'
|
|
539
|
-
|
|
540
|
-
// Returns 204 No Content
|
|
541
|
-
```
|
|
542
|
-
|
|
543
|
-
## Delete Purchase Discount % DELETE /store/skus/{sku.id#DOCS_GAME_SDK_STORE/data-models-sku-struct}/discounts/{user.id#DOCS_RESOURCES_USER/user-object}
|
|
544
|
-
|
|
545
|
-
Deletes the currently active discount on the given SKU for the given user. You **do not need** to call this after a user has made a discounted purchase; successful discounted purchases will automatically remove the discount for that user for subsequent purchases.
|
|
546
|
-
|
|
547
|
-
###### Example
|
|
548
|
-
|
|
549
|
-
```
|
|
550
|
-
curl -X DELETE https://discord.com/api/v6/store/skus/461618229171141643/discounts/53908232522183999 \
|
|
551
|
-
-H "Authorization: Bearer <token>" \
|
|
552
|
-
-H "Accept: application/json"
|
|
553
|
-
|
|
554
|
-
// Returns 204 No Content
|
|
555
|
-
```
|