Skip to content

refactor!: Invite classes #10888

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

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

refactor!: Invite classes #10888

wants to merge 9 commits into from

Conversation

Jiralite
Copy link
Member

@Jiralite Jiralite commented May 7, 2025

Please describe the changes this PR makes and why it should be merged:
Depending on the invite type, an invite class will be created, similar to components. This has the added benefit of stronger typings: group direct message invites cannot be deleted, they do not have target_application, etc.

The separation of properties was done per the API specification:

FriendInvite (discord/discord-api-docs#3659) was not created as applications can no longer seem to fetch them (returns unknown invite).

No other properties were added as they were not in the documentation.

Also contains miscellaneous fixes:

  • This nullish coalescing operator here was redundant, as adding channels already has a cache check.
    this.channel =
    this.client.channels._add(data.channel, this.guild, { cache: false }) ??
    this.client.channels.resolve(this.channelId);
    refactor!: Invite classes #10888 (comment)
  • Deleting an invite was typed to return the invite, but didn't
  • Approximate member and presence counts were typed to always return a number, but this is not true
  • with_counts is now configurable when fetching an invite

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 includes breaking changes (methods removed or renamed, parameters moved or removed)

@Jiralite Jiralite added this to the discord.js 15.0.0 milestone May 7, 2025
@Jiralite Jiralite requested a review from a team as a code owner May 7, 2025 08:57
Copy link

vercel bot commented May 7, 2025

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 May 8, 2025 11:42am
discord-js-guide ⬜️ Ignored (Inspect) Visit Preview May 8, 2025 11:42am

@Jiralite Jiralite changed the title refactor(ClientFetchInviteOptions): configurable withCounts refactor!: Invite classes May 7, 2025
@github-project-automation github-project-automation bot moved this from Todo to Review in Progress in discord.js May 7, 2025
@discordjs discordjs deleted a comment from Qjuh May 7, 2025
Jiralite added 4 commits May 7, 2025 18:12
Respecting the documentation as the channel object is not documented to emit with `INVITE_DELETE`, despite it doing so.
@Jiralite Jiralite requested a review from Qjuh May 7, 2025 18:05
@Jiralite Jiralite requested a review from Qjuh May 8, 2025 11:35
Sweepers only sweeps guild invites.
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