Skip to content

Commit

Permalink
feat(Guild): add disableInvites method (#8801)
Browse files Browse the repository at this point in the history
* 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 <kyradiscord@gmail.com>
  • Loading branch information
3 people committed Dec 2, 2022
1 parent 8f552a0 commit 45faa19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
11 changes: 11 additions & 0 deletions packages/discord.js/src/structures/Guild.js
Expand Up @@ -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<Guild>}
*/
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
Expand Down
1 change: 1 addition & 0 deletions packages/discord.js/typings/index.d.ts
Expand Up @@ -1281,6 +1281,7 @@ export class Guild extends AnonymousGuild {
public fetchWidget(): Promise<Widget>;
public fetchWidgetSettings(): Promise<GuildWidgetSettings>;
public leave(): Promise<Guild>;
public disableInvites(disabled?: boolean): Promise<Guild>;
public setAFKChannel(afkChannel: VoiceChannelResolvable | null, reason?: string): Promise<Guild>;
public setAFKTimeout(afkTimeout: number, reason?: string): Promise<Guild>;
public setBanner(banner: BufferResolvable | Base64Resolvable | null, reason?: string): Promise<Guild>;
Expand Down

0 comments on commit 45faa19

Please sign in to comment.