-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds premium interaction docs #6875
Conversation
Co-authored-by: MCausc78 <mcausc78@gmail.com>
@@ -36,6 +36,33 @@ When a user subscribes to your app, there are a few things you will need to impl | |||
|
|||
### Gating Premium Interactions | |||
|
|||
Each interaction payload includes an `entitlements` field containing an array of full [entitlement objects](#DOCS_MONETIZATION_ENTITLEMENTS/entitlement-object). You can use this field to determine if the user or guild is subscribed to your app. If the user or guild is not subscribed and you wish to present them with a means to do so you can use a [button](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/buttons) with a [premium style](#DOCS_INTERACTIONS_MESSAGE_COMPONENTS/button-object-button-styles) and a `sku_id` attached. You may also use these buttons to present users with options to make a [One-Time Purchase](#DOCS_MONETIZATION_ONE-TIME_PURCHASES). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This gets restated below, under Type 10 Interaction Response
:
discord-api-docs/docs/monetization/App_Subscriptions.md
Lines 77 to 81 in 8588250
If someone is already subscribed, this command will show the upgrade prompt with a disabled upgrade button. In order to avoid this, your interaction handler should check to see if the user or guild has an active entitlement for your SKU. | |
Each interaction payload includes an `entitlements` field containing an array of full [entitlement objects](#DOCS_MONETIZATION_ENTITLEMENTS/entitlement-object). | |
You can use this field to determine if the user or guild is subscribed to your app. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it's relevant in both cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah it's relevant in both cases.
it just seems redundant, since it's already started once here and then again under the sub header on the same page
Why Traceback (most recent call last):
File "/home/***/venv/lib/python3.10/site-packages/jishaku/features/python.py", line 190, in jsk_python
async for send, result in AsyncSender(executor): # type: ignore
File "/home/***/venv/lib/python3.10/site-packages/jishaku/functools.py", line 124, in _internal
value = await base.asend(self.send_value)
File "/home/***/venv/lib/python3.10/site-packages/jishaku/repl/compilation.py", line 210, in traverse
async for send, result in AsyncSender(func_g(*self.args)): # type: ignore
File "/home/***/venv/lib/python3.10/site-packages/jishaku/functools.py", line 124, in _internal
value = await base.asend(self.send_value)
File "<repl>", line 15, in _repl_coroutine
await _bot.http.request(
File "/home/***/venv/lib/python3.10/site-packages/discord/http.py", line 758, in request
raise HTTPException(response, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50035): Invalid Form Body
In components.0.components.0.sku_id: Invalid SKU
In components.0.components.0.custom_id: A custom id is required components = [
{
'type': 1, 'components': [
{
'type': 2,
'style': 6,
'sku_id': '521847234246082599', # nitro sku id (maybe)
'label': 'wdhsjshjs',
}
]
}
]
await _bot.http.request(
discord.http.Route('POST',
'/channels/{channel_id}/messages',
channel_id=_channel.id
), json={
'content': 'Hello world',
'components': components
}) (Unverified bot) |
Why are custom labels not supported for premium buttons? That's unfortunate for bots that want to provide multiple options in the response |
They can still have multiple buttons in a response. But we want clarity in each of the premium buttons and requiring sku_name & price is the best path forward right now. It's possible we can open this up in the future to not require sku name & price. |
Co-authored-by: codershiba <155646804+codershiba@users.noreply.github.com>
Co-authored-by: advaith <advaithj1@gmail.com>
Co-authored-by: Adrian Paschkowski <adrian.paschkowski@ruhr-uni-bochum.de>
Co-authored-by: val.le <81811276+valdotle@users.noreply.github.com>
Co-authored-by: val.le <81811276+valdotle@users.noreply.github.com>
Co-authored-by: val.le <81811276+valdotle@users.noreply.github.com>
Co-authored-by: val.le <81811276+valdotle@users.noreply.github.com>
if the image is being updated, might as well update the other buttons in it too - the green and maybe the red are outdated colors, and the grays are inconsistent |
Agree, I'll get those other colors updated. Thanks Advaith! |
179dfc2
to
0b7c265
Compare
This PR implements the new premium button style. Refs: - discord/discord-api-docs#6875
ButtonStyle.Premium
PREMIUM_REQUIRED
interaction response type