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(EntitlementManager): Support get entitlement #10606

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Jiralite
Copy link
Member

@Jiralite Jiralite commented Nov 19, 2024

Please describe the changes this PR makes and why it should be merged:

Status and versioning classification:

Copy link

vercel bot commented Nov 19, 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 20, 2024 9:14am
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview Nov 20, 2024 9:14am

/**
* Options used to fetch an entitlement
* @typedef {BaseFetchOptions} FetchEntitlementOptions
* @property {EntitlementResolvable} entitlement The entitlement to fetch
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be EntitlementResolvable instead of just Snowflake? Doesn't make much sense to fetch an entitlement using itself

Copy link
Member Author

@Jiralite Jiralite Nov 20, 2024

Choose a reason for hiding this comment

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

I added this for consistency reasons (message fetching, event fetching, thread member fetching, etc.), but we can remove it if we feel strongly about it.

async fetch({ limit, guild, user, skus, excludeEnded, cache = true, before, after } = {}) {
async fetch(options) {
if (!options) return this._fetchMany(options);
const { entitlement, cache, force } = options;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
const { entitlement, cache, force } = options;
const { entitlement, cache = true, force } = options;

return this._add(data, cache);
}

async _fetchMany({ limit, guild, user, skus, excludeEnded, excludeDelete, cache, before, after } = {}) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't cache default to true as it was previously?

Copy link
Member Author

@Jiralite Jiralite Nov 20, 2024

Choose a reason for hiding this comment

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

It already is defaulted to true in _add(). Adding true here isn't actually doing anything.

packages/discord.js/src/managers/EntitlementManager.js Outdated Show resolved Hide resolved
Co-authored-by: Danial Raza <[email protected]>
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.

2 participants