Skip to content

feat(invites): target users routes#1493

Open
Inbestigator wants to merge 10 commits intodiscordjs:mainfrom
Inbestigator:feat/new-invite-endpoints
Open

feat(invites): target users routes#1493
Inbestigator wants to merge 10 commits intodiscordjs:mainfrom
Inbestigator:feat/new-invite-endpoints

Conversation

@Inbestigator
Copy link

@Inbestigator Inbestigator commented Jan 18, 2026

Please describe the changes this PR makes and why it should be merged:
This PR adds the new routes and their responses for target users. It also adds the target_users_file key in a formdata version of RESTPostAPIChannelInviteJSONBody.

If applicable, please reference Discord API Docs PRs or commits that influenced this PR:
https://discord.com/developers/docs/change-log#new-invite-endpoints

@vercel
Copy link

vercel bot commented Jan 18, 2026

@Inbestigator is attempting to deploy a commit to the discordjs Team on Vercel.

A member of the Team first needs to authorize it.

@Inbestigator Inbestigator changed the title feat(invites): new target users routes feat(invites): target users routes Jan 18, 2026
@vladfrangu
Copy link
Member

Can you add this for API v9 too please?

Inbestigator and others added 2 commits January 22, 2026 08:14
Co-authored-by: Naiyar <137700126+imnaiyar@users.noreply.github.com>
@imnaiyar
Copy link
Contributor

Also missed roles on invite object.
ref: https://discord.com/developers/docs/resources/invite#invite-object-invite-structure

@Inbestigator
Copy link
Author

Also missed roles on invite object. ref: discord.com/developers/docs/resources/invite#invite-object-invite-structure

Oops, didn't realize invites changed, sorry

@Jiralite Jiralite linked an issue Jan 22, 2026 that may be closed by this pull request
Jiralite
Jiralite previously approved these changes Jan 25, 2026
@imnaiyar
Copy link
Contributor

imnaiyar commented Feb 11, 2026

discord/discord-api-docs#8117 acc to this, not all of the properties are returned for role objects in invites, might wanna partialize it or since the properties returned through this endpoint is known, we can maybe make an APIInviteRole interface or something. Not sure what would be the best here

@Jiralite
Copy link
Member

Checking the API specification, if it's updated, would be a good idea in that case.

@Inbestigator
Copy link
Author

Inbestigator commented Feb 12, 2026

export type APIInviteRole = Pick<APIRole, 'color' | 'colors' | 'icon' | 'id' | 'name' | 'position'>;

Comment on lines +600 to +613
export type RESTPostAPIChannelInviteFormDataBody = {
/**
* A csv file with a single column of user IDs for all the users able to accept this invite
*/
target_users_file?: unknown;
} & (
| RESTPostAPIChannelInviteJSONBody
| {
/**
* JSON stringified invite data
*/
payload_json?: string | undefined;
}
);
Copy link
Member

Choose a reason for hiding this comment

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

@Qjuh is this suitable for docs?

Copy link
Member

Choose a reason for hiding this comment

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

No, intersections never are. If possible interfaces should always be preferred from a docs perspective.

Copy link
Author

@Inbestigator Inbestigator Feb 12, 2026

Choose a reason for hiding this comment

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

This follows how the other instances of payload_json are done
Screenshot 2026-02-12 at 8 32 13 AM

Copy link
Member

Choose a reason for hiding this comment

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

And they are horrible from docs perspective too. I just answered Jiralite's question
https://discord.js.org/docs/packages/discord-api-types/0.38.38/v10/RESTPostAPIChannelMessageFormDataBody:TypeAlias

Copy link
Member

Choose a reason for hiding this comment

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

Doesn't mean it should block this PR, you can PR a proper version

Copy link
Author

Choose a reason for hiding this comment

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

what would be considered to be a "proper" fix for such a type?

Copy link
Contributor

@imnaiyar imnaiyar Feb 15, 2026

Choose a reason for hiding this comment

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

If i understood the issue correctly, something like this should work. do not mind the type names lol

interface NameWhtvX {
target_users_file?: unknown;
}


interface NameWhtvXWithJSONBody extends NameWhtvX, RESTPostAPIChannelInviteJSONBody {}

interface NameWhtvXWithPayload extends NameWhtvX {
payload_json?: string
}

type MainWhtv = NameWhtvXWithJSONBody | NameWhtvXWithPayload

| 'verification_level'
>;

export type APIInviteRole = Pick<APIRole, 'color' | 'colors' | 'icon' | 'id' | 'name' | 'position'>;
Copy link
Member

Choose a reason for hiding this comment

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

From a docs perspective Pick is not a good idea. Would be better to introduce this APIInviteRole as new interface and do

export interface APIRole extends APIInviteRole { ... }

moving the common properties to APIInviteRole.

Copy link
Author

Choose a reason for hiding this comment

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

but APIInviteRole is technically derivative of APIRole, so it feels kinda confusing to make the actual APIRole type an extension of it.

Copy link
Member

Choose a reason for hiding this comment

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

Confusing for whom? One is partial the other has more properties.

Copy link
Author

Choose a reason for hiding this comment

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

I feel like it would seem backwards when reading the source. If you guys want this I'm fine to do it, but the Pick is also a precedented pattern.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add roles to APIInvite

5 participants