Skip to content

Conversation

@sdanialraza
Copy link
Member

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)

@vercel
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 28, 2024 8:14am
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Nov 28, 2024 8:14am

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
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

@sdanialraza sdanialraza requested a review from Jiralite November 13, 2024 23:06
@Jiralite Jiralite dismissed their stale review November 14, 2024 00:02

Resolved.

@kodiakhq kodiakhq bot merged commit 108943a into discordjs:main Nov 28, 2024
7 checks passed
@sdanialraza sdanialraza deleted the feat/add-subscriptions-mainlib branch November 29, 2024 00:09
Jiralite added a commit that referenced this pull request Dec 2, 2024
* feat: add subscriptions

* types: fix fetch options types

* fix: correct properties in patch method

* chore: requested changes

Co-authored-by: Jiralite <[email protected]>

* fix: correct export syntax

* chore(Entitlement): mark `ends_at` as nullable`

* types(FetchSubscriptionOptions): add missing `cache` option

* Revert "types(FetchSubscriptionOptions): add missing `cache` option"

This reverts commit ba472bd.

* chore(Entitlement): mark `startsTimestamp` as nullable

* fix: requested changes

* docs(SubscriptionManager): correct return type

---------

Co-authored-by: Jiralite <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

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

6 participants