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

feat: add subscriptions #10541

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

sdanialraza
Copy link
Contributor

Please describe the changes this PR makes and why it should be merged:
Adds subscriptions for mainlib

Status and versioning classification:

  • Code changes have been tested against the Discord API, or there are no code changes
  • I know how to update typings and have done so, or typings don't need updating
  • This PR changes the library's interface (methods or parameters added)

Copy link

vercel bot commented Oct 7, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
discord-js ⬜️ Ignored (Inspect) Visit Preview Nov 21, 2024 10:58pm
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Nov 21, 2024 10:58pm

Copy link
Contributor

@OfficialSirH OfficialSirH left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Me parece bien

@sdanialraza sdanialraza marked this pull request as ready for review October 15, 2024 13:41
@sdanialraza sdanialraza requested a review from a team as a code owner October 15, 2024 13:41
@Jiralite Jiralite added this to the discord.js 14.17 milestone Oct 15, 2024
packages/discord.js/src/index.js Outdated Show resolved Hide resolved
packages/discord.js/src/index.js Outdated Show resolved Hide resolved
Copy link
Member

@Jiralite Jiralite left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the documentation1 and the specification2, ends_at may now be null. This means this logic needs to be modified as Date.parse(null) will result in NaN:

if ('ends_at' in data) {
/**
* The timestamp at which this entitlement is no longer valid
* <info>This is only `null` for test entitlements</info>
* @type {?number}
*/
this.endsTimestamp = Date.parse(data.ends_at);
} else {
this.endsTimestamp ??= null;
}

I say this, but the entitlement object itself on the documentation does not have it marked as nullable. It probably needs updating (discord/discord-api-docs#7268).

Footnotes

  1. https://discord.com/developers/docs/monetization/implementing-app-subscriptions#how-app-subscriptions-work

  2. https://github.com/discord/discord-api-spec/blob/c979cb269dbaf8cd09b8d0a39cc683d9623d8ce4/specs/openapi.json#L16491-L16495

packages/discord.js/typings/index.d.ts Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Review in Progress
Development

Successfully merging this pull request may close these issues.

Entitlement#isTest always returns false even though entitlement is a test entitlement
4 participants