mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 17:43:30 +01:00
feat(core): Add AbortSignal support. (#9042)
* feat: add abort signal to guilds api * feat: add to application commands, channels, and users classes * chore: finish up * chore: centralize types * chore: make requested changes * chore: make requested changes * refactor: consistently use empty objects * Update packages/core/src/api/webhook.ts Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * chore: make requested changes * refactor: update `setVoiceState` after rebase * chore: requested changes * refactor: use -types interface for query --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { makeURLSearchParams, type REST } from '@discordjs/rest';
|
||||
import { makeURLSearchParams, type RequestData, type REST } from '@discordjs/rest';
|
||||
import { Routes, type RESTGetAPIInviteQuery, type RESTGetAPIInviteResult } from 'discord-api-types/v10';
|
||||
|
||||
export class InvitesAPI {
|
||||
@@ -9,10 +9,13 @@ export class InvitesAPI {
|
||||
*
|
||||
* @see {@link https://discord.com/developers/docs/resources/invite#get-invite}
|
||||
* @param code - The invite code
|
||||
* @param query - The options to use when fetching the invite
|
||||
* @param options - The options to use when fetching the invite
|
||||
*/
|
||||
public async get(code: string, options: RESTGetAPIInviteQuery = {}) {
|
||||
public async get(code: string, query: RESTGetAPIInviteQuery = {}, { signal }: Pick<RequestData, 'signal'> = {}) {
|
||||
return this.rest.get(Routes.invite(code), {
|
||||
query: makeURLSearchParams(options),
|
||||
query: makeURLSearchParams(query),
|
||||
signal,
|
||||
}) as Promise<RESTGetAPIInviteResult>;
|
||||
}
|
||||
|
||||
@@ -21,9 +24,9 @@ export class InvitesAPI {
|
||||
*
|
||||
* @see {@link https://discord.com/developers/docs/resources/invite#delete-invite}
|
||||
* @param code - The invite code
|
||||
* @param reason - The reason for deleting the invite
|
||||
* @param options - The options to use when deleting the invite
|
||||
*/
|
||||
public async delete(code: string, reason?: string) {
|
||||
await this.rest.delete(Routes.invite(code), { reason });
|
||||
public async delete(code: string, { reason, signal }: Pick<RequestData, 'reason' | 'signal'> = {}) {
|
||||
await this.rest.delete(Routes.invite(code), { reason, signal });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user