move the invite function to Application

This commit is contained in:
TheDevYellowy 2022-07-31 00:42:51 -05:00
parent f95436f44b
commit 1f587eff99
3 changed files with 25 additions and 25 deletions

View File

@ -142,30 +142,6 @@ class ClientApplication extends Application {
this._patch(app.application); this._patch(app.application);
return this; 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<ClientApplication>}
*/
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; module.exports = ClientApplication;

View File

@ -75,6 +75,30 @@ class Application extends Base {
return new Date(this.createdTimestamp); 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 {number} permissions The permissions for the bot in number form
* @returns nothing :)
*/
async invite(guild_id, 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,
permissions,
}
});
console.log(res)
return;
}
/** /**
* A link to the application's icon. * A link to the application's icon.
* @param {StaticImageURLOptions} [options={}] Options for the Image URL * @param {StaticImageURLOptions} [options={}] Options for the Image URL

2
typings/index.d.ts vendored
View File

@ -337,6 +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 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;
@ -874,7 +875,6 @@ export class ClientApplication extends Application {
public readonly partial: boolean; public readonly partial: boolean;
public rpcOrigins: string[]; public rpcOrigins: string[];
public fetch(): Promise<ClientApplication>; public fetch(): Promise<ClientApplication>;
public invite(guildID: string, permissions: number): Promise<ClientApplication>;
} }
export class ClientPresence extends Presence { export class ClientPresence extends Presence {