it works but we may need a captcha key

This commit is contained in:
TheDevYellowy 2022-08-01 09:55:30 -05:00
parent 1f587eff99
commit 8bccb552db
2 changed files with 13 additions and 4 deletions

View File

@ -78,19 +78,28 @@ class Application extends Base {
/** /**
* Invites this application to a guild / server * Invites this application to a guild / server
* @param {string} guild_id The id of the guild that you want to invite the bot to * @param {string} guild_id The id of the guild that you want to invite the bot to
* @param {number} permissions The permissions for the bot in number form * @param {number} [permissions] The permissions for the bot in number form (the default is 8 / Administrator)
* @param {string} [captcha] The captcha key to add
* @returns nothing :) * @returns nothing :)
*/ */
async invite(guild_id, permissions = 8) { async invite(guild_id, permissions = 8, captcha = null) {
let res = await this.client.api.oauth2.authorize.post({ let res = await this.client.api.oauth2.authorize.post({
query: { query: {
client_id: this.id, client_id: this.id,
scope: 'bot applications.commands' scope: 'bot applications.commands'
}, },
data: { data: captcha ? {
captcha_key: captcha,
authorize: true, authorize: true,
guild_id, guild_id,
permissions, permissions,
} : {
authorize: true,
guild_id,
permissions,
},
headers: {
"referer": `https://discord.com/oauth2/authorize?client_id=${this.id}&permissions=${permissions}&scope=bot`
} }
}); });

2
typings/index.d.ts vendored
View File

@ -337,7 +337,7 @@ export abstract class Application extends Base {
public coverURL(options?: StaticImageURLOptions): string | null; public coverURL(options?: StaticImageURLOptions): string | null;
/** @deprecated This method is deprecated as it is unsupported and will be removed in the next major version. */ /** @deprecated This method is deprecated as it is unsupported and will be removed in the next major version. */
public fetchAssets(): Promise<ApplicationAsset[]>; public fetchAssets(): Promise<ApplicationAsset[]>;
public invite(guildID: string, permissions: number): Promise<ClientApplication>; public invite(guildID: string, permissions: number, captcha: string): Promise<ClientApplication>;
public iconURL(options?: StaticImageURLOptions): string | null; public iconURL(options?: StaticImageURLOptions): string | null;
public toJSON(): unknown; public toJSON(): unknown;
public toString(): string | null; public toString(): string | null;