Merge pull request #232 from TheDevYellowy/main

feat(Application): Add invite function
This commit is contained in:
Cinnamon 2022-08-01 22:09:21 +07:00 committed by GitHub
commit a21d28295f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 0 deletions

View File

@ -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

1
typings/index.d.ts vendored
View File

@ -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<ApplicationAsset[]>;
public invite(guildID: string, permissions: bigint, captcha: string): null;
public iconURL(options?: StaticImageURLOptions): string | null;
public toJSON(): unknown;
public toString(): string | null;