Skip to content

Commit

Permalink
feat(Guild): Edit MFA level (#1473)
Browse files Browse the repository at this point in the history
Co-authored-by: bsian03 <[email protected]>
  • Loading branch information
conorwastakenwastaken and bsian03 authored Jan 22, 2024
1 parent e0c352d commit 3b0dd35
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ declare namespace Eris {
type GuildScheduledEventPrivacyLevel = Constants["GuildScheduledEventPrivacyLevel"][keyof Constants["GuildScheduledEventPrivacyLevel"]];
type GuildScheduledEventStatus = Constants["GuildScheduledEventStatus"][keyof Constants["GuildScheduledEventStatus"]];
type GuildWidgetStyles = Constants["GuildWidgetStyles"][keyof Constants["GuildWidgetStyles"]];
type MFALevel = Constants["MFALevels"][keyof Constants["MFALevels"]];
type NSFWLevel = Constants["GuildNSFWLevels"][keyof Constants["GuildNSFWLevels"]];
type PossiblyUncachedGuild = Guild | Uncached;
type PossiblyUncachedGuildScheduledEvent = GuildScheduledEvent | Uncached;
Expand Down Expand Up @@ -147,7 +148,6 @@ declare namespace Eris {
type MessageActivityTypes = Constants["MessageActivityTypes"][keyof Constants["MessageActivityTypes"]];
type MessageContent = string | AdvancedMessageContent;
type MessageContentEdit = string | AdvancedMessageContentEdit;
type MFALevel = Constants["MFALevels"][keyof Constants["MFALevels"]];
type PossiblyUncachedMessage = Message | { channel: TextableChannel | { id: string; guild?: Uncached }; guildID?: string; id: string };

// Permission
Expand Down Expand Up @@ -1142,6 +1142,9 @@ declare namespace Eris {
expireBehavior?: string;
expireGracePeriod?: string;
}
interface MFALevelResponse {
level: MFALevel;
}
interface PruneMemberOptions extends GetPruneOptions {
computePruneCount?: boolean;
reason?: string;
Expand Down Expand Up @@ -2641,6 +2644,7 @@ declare namespace Eris {
): Promise<Emoji>;
editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise<void>;
editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise<Member>;
editGuildMFALevel(guildID: string, level: MFALevel, reason?: string): Promise<MFALevelResponse>;
editGuildScheduledEvent<T extends GuildScheduledEventEntityTypes>(guildID: string, eventID: string, event: GuildScheduledEventEditOptions<T>, reason?: string): Promise<GuildScheduledEvent<T>>;
editGuildSticker(guildID: string, stickerID: string, options?: EditStickerOptions, reason?: string): Promise<Sticker>;
editGuildTemplate(guildID: string, code: string, options: GuildTemplateOptions): Promise<GuildTemplate>;
Expand Down Expand Up @@ -3067,6 +3071,7 @@ declare namespace Eris {
editEmoji(emojiID: string, options: { name: string; roles?: string[] }, reason?: string): Promise<Emoji>;
editIntegration(integrationID: string, options: IntegrationOptions): Promise<void>;
editMember(memberID: string, options: MemberOptions, reason?: string): Promise<Member>;
editMFALevel(level: MFALevel, reason?: string): Promise<MFALevelResponse>;
/** @deprecated */
editNickname(nick: string): Promise<void>;
editRole(roleID: string, options: RoleOptions): Promise<Role>;
Expand Down
14 changes: 14 additions & 0 deletions lib/Client.js
Original file line number Diff line number Diff line change
Expand Up @@ -1784,6 +1784,20 @@ class Client extends EventEmitter {
}).then((member) => new Member(member, this.guilds.get(guildID), this));
}

/**
* Edit a guild's MFA level (multi-factor authentication). Note: The bot account must be the owner of the guild to be able to edit the MFA status.
* @arg {String} guildID The ID of the guild
* @arg {Number} level The new MFA level, `0` to disable MFA, `1` to enable it
* @arg {String} [reason] The reason to be displayed in audit logs
* @returns {Promise<Object>} An object containing a `level` (Number) key, indicating the new MFA level
*/
editGuildMFALevel(guildID, level, reason) {
return this.requestHandler.request("POST", Endpoints.GUILD_MFA_LEVEL(guildID), true, {
level: level,
reason: reason
});
}

/**
* Edit a guild scheduled event
* @arg {String} guildID The guild ID where the event will be edited
Expand Down
1 change: 1 addition & 0 deletions lib/rest/Endpoints.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions lib/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -827,6 +827,16 @@ class Guild extends Base {
return this._client.editGuildMember.call(this._client, this.id, memberID, options, reason);
}

/**
* Edit the guild's MFA level (multi-factor authentication). Note: The bot account must be the owner of the guild to be able to edit the MFA status.
* @param {Number} level The new MFA level, `0` to disable MFA, `1` to enable it
* @param {String} [reason] The reason to be displayed in audit logs
* @returns {Promise<Object>} An object containing a `level` (Number) key, indicating the new MFA level
*/
editMFALevel(level, reason) {
return this._client.editGuildMFALevel.call(this._client, this.id, level, reason);
}

/**
* [DEPRECATED] Edit the bot's nickname in the guild
* @arg {String} nick The nickname
Expand Down

0 comments on commit 3b0dd35

Please sign in to comment.