refactor: clean code
@TheDevYellowy :))
This commit is contained in:
parent
3bcf936636
commit
196c03f8cc
@ -1431,7 +1431,7 @@ class Guild extends AnonymousGuild {
|
||||
|
||||
/**
|
||||
* Marks the guild as read
|
||||
* @returns {undefined} nothing :)
|
||||
* @returns {Promise<void>} nothing :)
|
||||
* @example
|
||||
* const guild = client.guilds.fetch('222078108977594368');
|
||||
* guild.read();
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
const process = require('node:process');
|
||||
const { ClientApplicationAssetTypes, Endpoints } = require('../../util/Constants');
|
||||
const Permissions = require('../../util/Permissions');
|
||||
const SnowflakeUtil = require('../../util/SnowflakeUtil');
|
||||
const Base = require('../Base');
|
||||
|
||||
@ -77,29 +78,30 @@ class Application extends Base {
|
||||
|
||||
/**
|
||||
* 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 {Snowflake} guild_id The id of the guild that you want to invite the bot to
|
||||
* @param {PermissionResolvable} [permissions] The permissions for the bot in number form (the default is 8 / Administrator)
|
||||
* @param {string} [captcha] The captcha key to add
|
||||
* @returns {undefined} nothing :)
|
||||
* @returns {Promise<void>} nothing :)
|
||||
*/
|
||||
async invite(guild_id, permissions = 8, captcha = null) {
|
||||
async invite(guild_id, permissions = 0n, captcha = null) {
|
||||
permissions = Permissions.resolve(permissions);
|
||||
const postData = {
|
||||
authorize: true,
|
||||
guild_id,
|
||||
permissions: '0',
|
||||
};
|
||||
if (permissions) {
|
||||
postData.permissions = permissions;
|
||||
}
|
||||
if (captcha && typeof captcha === 'string' && captcha.length > 0) {
|
||||
postData.captcha = captcha;
|
||||
}
|
||||
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,
|
||||
},
|
||||
data: postData,
|
||||
headers: {
|
||||
referer: `https://discord.com/oauth2/authorize?client_id=${this.id}&permissions=${permissions}&scope=bot`,
|
||||
},
|
||||
|
4
typings/index.d.ts
vendored
4
typings/index.d.ts
vendored
@ -337,7 +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 invite(guildID: Snowflake, permissions?: PermissionResolvable, captcha?: string): Promise<undefined>;
|
||||
public iconURL(options?: StaticImageURLOptions): string | null;
|
||||
public toJSON(): unknown;
|
||||
public toString(): string | null;
|
||||
@ -1236,7 +1236,7 @@ export class Guild extends AnonymousGuild {
|
||||
public readonly maximumBitrate: number;
|
||||
public createTemplate(name: string, description?: string): Promise<GuildTemplate>;
|
||||
public delete(): Promise<Guild>;
|
||||
public read(): undefined;
|
||||
public read(): Promise<undefined>;
|
||||
public discoverySplashURL(options?: StaticImageURLOptions): string | null;
|
||||
public edit(data: GuildEditData, reason?: string): Promise<Guild>;
|
||||
public editWelcomeScreen(data: WelcomeScreenEditData): Promise<WelcomeScreen>;
|
||||
|
Loading…
Reference in New Issue
Block a user