Merge pull request #232 from TheDevYellowy/main
feat(Application): Add invite function
This commit is contained in:
commit
a21d28295f
@ -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
1
typings/index.d.ts
vendored
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user