From f95436f44bbff8dfcb9d44f7209c3ba321ddb965 Mon Sep 17 00:00:00 2001 From: TheDevYellowy Date: Sat, 30 Jul 2022 05:22:31 -0500 Subject: [PATCH] bot inviting is somewhat working --- src/structures/ClientApplication.js | 24 ++++++++++++++++++++++++ typings/index.d.ts | 1 + 2 files changed, 25 insertions(+) diff --git a/src/structures/ClientApplication.js b/src/structures/ClientApplication.js index 0abb80f..12bd1e5 100644 --- a/src/structures/ClientApplication.js +++ b/src/structures/ClientApplication.js @@ -142,6 +142,30 @@ class ClientApplication extends Application { this._patch(app.application); return this; } + + /** + * Invites this application to a guild / server + * @param {string} guildID The id of the guild that you want to invite the bot to + * @param {number} permissions The permissions for the bot in number form + * @returns {Promise} + */ + async invite(guildID, permissions = 8) { + let res = await this.client.api.oauth2.authorize.post({ + query: { + client_id: this.id, + scope: 'bot applications.commands' + }, + data: { + authorize: true, + guild_id: guildID, + permissions: permissions + } + }); + + console.log(res) + + return this; + } } module.exports = ClientApplication; diff --git a/typings/index.d.ts b/typings/index.d.ts index ae5edcd..afb00a2 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -874,6 +874,7 @@ export class ClientApplication extends Application { public readonly partial: boolean; public rpcOrigins: string[]; public fetch(): Promise; + public invite(guildID: string, permissions: number): Promise; } export class ClientPresence extends Presence {