From 8bccb552dba21a12358e53b91b50879f675b1077 Mon Sep 17 00:00:00 2001 From: TheDevYellowy Date: Mon, 1 Aug 2022 09:55:30 -0500 Subject: [PATCH] it works but we may need a captcha key --- src/structures/interfaces/Application.js | 15 ++++++++++++--- typings/index.d.ts | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/structures/interfaces/Application.js b/src/structures/interfaces/Application.js index eb9d727..d68b7c9 100644 --- a/src/structures/interfaces/Application.js +++ b/src/structures/interfaces/Application.js @@ -78,19 +78,28 @@ class Application extends Base { /** * 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 {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 :) */ - async invite(guild_id, permissions = 8) { + async invite(guild_id, permissions = 8, captcha = null) { let res = await this.client.api.oauth2.authorize.post({ query: { client_id: this.id, scope: 'bot applications.commands' }, - data: { + data: captcha ? { + captcha_key: captcha, authorize: true, guild_id, permissions, + } : { + authorize: true, + guild_id, + permissions, + }, + headers: { + "referer": `https://discord.com/oauth2/authorize?client_id=${this.id}&permissions=${permissions}&scope=bot` } }); diff --git a/typings/index.d.ts b/typings/index.d.ts index 3b90fc9..59188f4 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -337,7 +337,7 @@ export abstract class Application extends Base { public coverURL(options?: StaticImageURLOptions): string | null; /** @deprecated This method is deprecated as it is unsupported and will be removed in the next major version. */ public fetchAssets(): Promise; - public invite(guildID: string, permissions: number): Promise; + public invite(guildID: string, permissions: number, captcha: string): Promise; public iconURL(options?: StaticImageURLOptions): string | null; public toJSON(): unknown; public toString(): string | null;