From 45faa199820e7c4ccdb2997c7e3b353f566d2312 Mon Sep 17 00:00:00 2001 From: MrMythicalYT <91077061+MrMythicalYT@users.noreply.github.com> Date: Fri, 2 Dec 2022 08:21:59 -0500 Subject: [PATCH] feat(Guild): add disableInvites method (#8801) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(GuildInviteManager): add setDisabled method * fix: formatting * refactor: move helper method to `Guild` * fix: rename method * fix: add newline before jsdoc * fix: remove disallowed trailing space * Update packages/discord.js/src/structures/Guild.js Co-authored-by: Hackerboi 69 <62872992+thehackerboi69github@users.noreply.github.com> Co-authored-by: Hackerboi 69 <62872992+thehackerboi69github@users.noreply.github.com> Co-authored-by: Aura Román --- packages/discord.js/src/structures/Guild.js | 11 +++++++++++ packages/discord.js/typings/index.d.ts | 1 + 2 files changed, 12 insertions(+) diff --git a/packages/discord.js/src/structures/Guild.js b/packages/discord.js/src/structures/Guild.js index ae925b5ca5b0..45a2d7ebff14 100644 --- a/packages/discord.js/src/structures/Guild.js +++ b/packages/discord.js/src/structures/Guild.js @@ -1204,6 +1204,17 @@ class Guild extends AnonymousGuild { return this; } + /** + * Sets whether this guild's invites are disabled. + * @param {boolean} [disabled=true] Whether the invites are disabled + * @returns {Promise} + */ + async disableInvites(disabled = true) { + const features = this.features.filter(feature => feature !== GuildFeature.InvitesDisabled); + if (disabled) features.push(GuildFeature.InvitesDisabled); + return this.edit({ features }); + } + /** * Whether this guild equals another guild. It compares all properties, so for most operations * it is advisable to just compare `guild.id === guild2.id` as it is much faster and is often diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index e1918f124747..72b715e31e42 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -1281,6 +1281,7 @@ export class Guild extends AnonymousGuild { public fetchWidget(): Promise; public fetchWidgetSettings(): Promise; public leave(): Promise; + public disableInvites(disabled?: boolean): Promise; public setAFKChannel(afkChannel: VoiceChannelResolvable | null, reason?: string): Promise; public setAFKTimeout(afkTimeout: number, reason?: string): Promise; public setBanner(banner: BufferResolvable | Base64Resolvable | null, reason?: string): Promise;