Skip to content
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

Add support for entitlement (App Subscriptions) #9856

Closed
JMTK opened this issue Sep 27, 2023 · 4 comments · Fixed by #9907
Closed

Add support for entitlement (App Subscriptions) #9856

JMTK opened this issue Sep 27, 2023 · 4 comments · Fixed by #9907

Comments

@JMTK
Copy link
Contributor

JMTK commented Sep 27, 2023

Which application or package is this feature request for?

discord.js

Feature


New entitlement events:

https://discord.com/developers/docs/monetization/entitlements#gateway-events

Fires when a user subscribes to a SKU. Contains an entitlement object.

PREMIUM_REQUIRED Interaction Response

https://discord.com/developers/docs/monetization/entitlements#using-entitlements-in-interactions

If your app has monetization enabled, it will have access to a new PREMIUM_REQUIRED interaction response (type: 10). This can be sent in response to any kind of interaction. It does not allow a content field.

Entitlements class/endpoints

https://discord.com/developers/docs/monetization/entitlements#entitlement-object

{
    "id": "1019653849998299136",
    "sku_id": "1019475255913222144",
    "application_id": "1019370614521200640",
    "user_id": "771129655544643584",
    "promotion_id": null,
    "type": 8,
    "deleted": false,
    "gift_code_flags": 0,
    "consumed": false,
    "starts_at": "2022-09-14T17:00:18.704163+00:00",
    "ends_at": "2022-10-14T17:00:18.704163+00:00",
    "guild_id": "1015034326372454400",
    "subscription_id": "1019653835926409216"
}

Ideal solution or implementation

client
.on('entitlementCreate', () => {})
.on('entitlementUpdate', () => {})
.on('entitlementDelete', () => {})

Alternative solutions or implementations

No response

Other context

No response

@JMTK
Copy link
Contributor Author

JMTK commented Sep 28, 2023

Is there any way to temporarily support this? I was trying to do something like:

return interaction.reply({
    body: {
        type: 10,
        data: {}
    }
});

But in InteractionResponses.js, it hardcodes the body and type even if you pass it in:

await this.client.rest.post(Routes.interactionCallback(this.id, this.token), {
  body: {
    type: InteractionResponseType.ChannelMessageWithSource,
    data,
  },
  files,
  auth: false,
});

@Renegade334
Copy link
Contributor

dependency: discordjs/discord-api-types#833

@monbrey
Copy link
Member

monbrey commented Sep 28, 2023

Is there any way to temporarily support this?

The body is hard coded because each method is a specific response type. We don't support overwriting the body via these, but you're welcome to make the client.rest.post call yourself with any body you like.

@JMTK
Copy link
Contributor Author

JMTK commented Sep 29, 2023

Is there any way to temporarily support this?

The body is hard coded because each method is a specific response type. We don't support overwriting the body via these, but you're welcome to make the client.rest.post call yourself with any body you like.

FWIW, the function signature in Typescript allows you to pass a body in to this. Should that be changed with the PR to hide it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants