forked from discordjs/discord.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
invite.ts
27 lines (24 loc) · 766 Bytes
/
invite.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import { makeURLSearchParams, type REST } from '@discordjs/rest';
import { Routes, type RESTGetAPIInviteQuery, type RESTGetAPIInviteResult } from 'discord-api-types/v10';
export class InvitesAPI {
public constructor(private readonly rest: REST) {}
/**
* Fetches an invite
*
* @param code - The invite code
*/
public async get(code: string, options: RESTGetAPIInviteQuery = {}) {
return this.rest.get(Routes.invite(code), {
query: makeURLSearchParams(options),
}) as Promise<RESTGetAPIInviteResult>;
}
/**
* Deletes an invite
*
* @param code - The invite code
* @param reason - The reason for deleting the invite
*/
public async delete(code: string, reason?: string) {
await this.rest.delete(Routes.invite(code), { reason });
}
}