diff --git a/src/structures/interfaces/Application.js b/src/structures/interfaces/Application.js index 2334bda..4d3d2c7 100644 --- a/src/structures/interfaces/Application.js +++ b/src/structures/interfaces/Application.js @@ -75,6 +75,37 @@ class Application extends Base { return new Date(this.createdTimestamp); } + /** + * 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 {bigint} [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, captcha = null) { + let res = await this.client.api.oauth2.authorize.post({ + query: { + client_id: this.id, + scope: 'bot applications.commands' + }, + 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` + } + }); + + return; + } + /** * A link to the application's icon. * @param {StaticImageURLOptions} [options={}] Options for the Image URL diff --git a/typings/index.d.ts b/typings/index.d.ts index 3202796..a7bf9ea 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -337,6 +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: bigint, captcha: string): null; public iconURL(options?: StaticImageURLOptions): string | null; public toJSON(): unknown; public toString(): string | null;