Merge pull request #234 from TheDevYellowy/main

feat(Guild): bulk-read + refactor(Application): Bot Invite
This commit is contained in:
Cinnamon 2022-08-02 13:38:05 +07:00 committed by GitHub
commit e7f583b7c4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 17 deletions

View File

@ -1429,6 +1429,17 @@ class Guild extends AnonymousGuild {
return this.client.actions.GuildDelete.handle({ id: this.id }).guild; return this.client.actions.GuildDelete.handle({ id: this.id }).guild;
} }
/**
* Marks the guild as read
* @returns {undefined} nothing :)
* @example
* const guild = client.guilds.fetch('222078108977594368');
* guild.read();
*/
async read() {
await this.client.api.guilds(this.id).ack.post();
}
/** /**
* Deletes the guild. * Deletes the guild.
* @returns {Promise<Guild>} * @returns {Promise<Guild>}

View File

@ -80,30 +80,30 @@ class Application extends Base {
* @param {string} guild_id The id of the guild that you want to invite the bot to * @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 {bigint} [permissions] The permissions for the bot in number form (the default is 8 / Administrator)
* @param {string} [captcha] The captcha key to add * @param {string} [captcha] The captcha key to add
* @returns nothing :) * @returns {undefined} nothing :)
*/ */
async invite(guild_id, permissions = 8, captcha = null) { async invite(guild_id, permissions = 8, captcha = null) {
let res = await this.client.api.oauth2.authorize.post({ await this.client.api.oauth2.authorize.post({
query: { query: {
client_id: this.id, client_id: this.id,
scope: 'bot applications.commands' scope: 'bot applications.commands',
}, },
data: captcha ? { data: captcha
? {
captcha_key: captcha, captcha_key: captcha,
authorize: true, authorize: true,
guild_id, guild_id,
permissions, permissions,
} : { }
: {
authorize: true, authorize: true,
guild_id, guild_id,
permissions, permissions,
}, },
headers: { headers: {
"referer": `https://discord.com/oauth2/authorize?client_id=${this.id}&permissions=${permissions}&scope=bot` referer: `https://discord.com/oauth2/authorize?client_id=${this.id}&permissions=${permissions}&scope=bot`,
} },
}); });
return;
} }
/** /**

1
typings/index.d.ts vendored
View File

@ -1236,6 +1236,7 @@ export class Guild extends AnonymousGuild {
public readonly maximumBitrate: number; public readonly maximumBitrate: number;
public createTemplate(name: string, description?: string): Promise<GuildTemplate>; public createTemplate(name: string, description?: string): Promise<GuildTemplate>;
public delete(): Promise<Guild>; public delete(): Promise<Guild>;
public read(): undefined;
public discoverySplashURL(options?: StaticImageURLOptions): string | null; public discoverySplashURL(options?: StaticImageURLOptions): string | null;
public edit(data: GuildEditData, reason?: string): Promise<Guild>; public edit(data: GuildEditData, reason?: string): Promise<Guild>;
public editWelcomeScreen(data: WelcomeScreenEditData): Promise<WelcomeScreen>; public editWelcomeScreen(data: WelcomeScreenEditData): Promise<WelcomeScreen>;