From bccec00ec136d816b5479999e278dfeae1064496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conor=E2=84=A2?= Date: Wed, 17 Jan 2024 16:46:26 +0000 Subject: [PATCH 1/8] Edit guild MFA --- index.d.ts | 2 ++ lib/Client.js | 15 +++++++++++++++ lib/rest/Endpoints.js | 1 + lib/structures/Guild.js | 10 ++++++++++ 4 files changed, 28 insertions(+) diff --git a/index.d.ts b/index.d.ts index 61baa5823..4d8c916e1 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2641,6 +2641,7 @@ declare namespace Eris { ): Promise; editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise; editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise; + editGuildMFALevel(guildID: string, level: 0 | 1, reason?: string): Promise; editGuildScheduledEvent(guildID: string, eventID: string, event: GuildScheduledEventEditOptions, reason?: string): Promise>; editGuildSticker(guildID: string, stickerID: string, options?: EditStickerOptions, reason?: string): Promise; editGuildTemplate(guildID: string, code: string, options: GuildTemplateOptions): Promise; @@ -3067,6 +3068,7 @@ declare namespace Eris { editEmoji(emojiID: string, options: { name: string; roles?: string[] }, reason?: string): Promise; editIntegration(integrationID: string, options: IntegrationOptions): Promise; editMember(memberID: string, options: MemberOptions, reason?: string): Promise; + editMFALevel(level: 0 | 1, reason?: string): Promise; /** @deprecated */ editNickname(nick: string): Promise; editRole(roleID: string, options: RoleOptions): Promise; diff --git a/lib/Client.js b/lib/Client.js index a0f4e11a0..05c1c8897 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -1784,6 +1784,21 @@ class Client extends EventEmitter { }).then((member) => new Member(member, this.guilds.get(guildID), this)); } + /** + * Edit a guild's MFA level (multi-factor authentication) + * @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} + */ + 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 diff --git a/lib/rest/Endpoints.js b/lib/rest/Endpoints.js index dbb06bd36..84d8c1e12 100644 --- a/lib/rest/Endpoints.js +++ b/lib/rest/Endpoints.js @@ -58,6 +58,7 @@ module.exports.GUILD_MEMBER_ROLE = (guildID, memberID, roleID) module.exports.GUILD_MEMBERS = (guildID) => `/guilds/${guildID}/members`; module.exports.GUILD_MEMBERS_SEARCH = (guildID) => `/guilds/${guildID}/members/search`; module.exports.GUILD_MESSAGES_SEARCH = (guildID) => `/guilds/${guildID}/messages/search`; +module.exports.GUILD_MFA_LEVEL = (guildID) => `/guilds/${guildID}/mfa`; module.exports.GUILD_PREVIEW = (guildID) => `/guilds/${guildID}/preview`; module.exports.GUILD_PRUNE = (guildID) => `/guilds/${guildID}/prune`; module.exports.GUILD_ROLE = (guildID, roleID) => `/guilds/${guildID}/roles/${roleID}`; diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 1a2e06bf6..0fecd84bc 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -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) + * @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} + */ + 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 From 5da45371534ce753ce3318322a3c1c49199d5e18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conor=E2=84=A2?= Date: Fri, 19 Jan 2024 20:10:05 +0000 Subject: [PATCH 2/8] Fix --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 4d8c916e1..d1a5ae14b 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2641,7 +2641,7 @@ declare namespace Eris { ): Promise; editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise; editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise; - editGuildMFALevel(guildID: string, level: 0 | 1, reason?: string): Promise; + editGuildMFALevel(guildID: string, level: MFALevel, reason?: string): Promise; editGuildScheduledEvent(guildID: string, eventID: string, event: GuildScheduledEventEditOptions, reason?: string): Promise>; editGuildSticker(guildID: string, stickerID: string, options?: EditStickerOptions, reason?: string): Promise; editGuildTemplate(guildID: string, code: string, options: GuildTemplateOptions): Promise; @@ -3068,7 +3068,7 @@ declare namespace Eris { editEmoji(emojiID: string, options: { name: string; roles?: string[] }, reason?: string): Promise; editIntegration(integrationID: string, options: IntegrationOptions): Promise; editMember(memberID: string, options: MemberOptions, reason?: string): Promise; - editMFALevel(level: 0 | 1, reason?: string): Promise; + editMFALevel(level: MFALevel, reason?: string): Promise; /** @deprecated */ editNickname(nick: string): Promise; editRole(roleID: string, options: RoleOptions): Promise; From dc6c13cb8c9d2ae1682a4c32c2c0f7a94339b259 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conor=E2=84=A2?= Date: Sun, 21 Jan 2024 23:02:56 +0000 Subject: [PATCH 3/8] Add note --- lib/Client.js | 2 +- lib/structures/Guild.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Client.js b/lib/Client.js index 05c1c8897..c0fbe0816 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -1785,7 +1785,7 @@ class Client extends EventEmitter { } /** - * Edit a guild's MFA level (multi-factor authentication) + * 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 diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index 0fecd84bc..ee3e0d55f 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -828,7 +828,7 @@ class Guild extends Base { } /** - * Edit the guild's MFA level (multi-factor authentication) + * 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} From 945e0c7ed1a4d3ef697b1ebec77838681f8ea6d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conor=E2=84=A2?= Date: Sun, 21 Jan 2024 23:15:35 +0000 Subject: [PATCH 4/8] TS Docs: Return object with `level` key --- index.d.ts | 8 +++++--- lib/Client.js | 2 +- lib/structures/Guild.js | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/index.d.ts b/index.d.ts index d1a5ae14b..222df58ba 100644 --- a/index.d.ts +++ b/index.d.ts @@ -147,7 +147,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 @@ -1142,6 +1141,9 @@ declare namespace Eris { expireBehavior?: string; expireGracePeriod?: string; } + interface MFALevel { + level: Constants["MFALevels"][keyof Constants["MFALevels"]] + } interface PruneMemberOptions extends GetPruneOptions { computePruneCount?: boolean; reason?: string; @@ -2641,7 +2643,7 @@ declare namespace Eris { ): Promise; editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise; editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise; - editGuildMFALevel(guildID: string, level: MFALevel, reason?: string): Promise; + editGuildMFALevel(guildID: string, level: Pick, reason?: string): Promise; editGuildScheduledEvent(guildID: string, eventID: string, event: GuildScheduledEventEditOptions, reason?: string): Promise>; editGuildSticker(guildID: string, stickerID: string, options?: EditStickerOptions, reason?: string): Promise; editGuildTemplate(guildID: string, code: string, options: GuildTemplateOptions): Promise; @@ -3068,7 +3070,7 @@ declare namespace Eris { editEmoji(emojiID: string, options: { name: string; roles?: string[] }, reason?: string): Promise; editIntegration(integrationID: string, options: IntegrationOptions): Promise; editMember(memberID: string, options: MemberOptions, reason?: string): Promise; - editMFALevel(level: MFALevel, reason?: string): Promise; + editMFALevel(level: Pick, reason?: string): Promise; /** @deprecated */ editNickname(nick: string): Promise; editRole(roleID: string, options: RoleOptions): Promise; diff --git a/lib/Client.js b/lib/Client.js index c0fbe0816..af135ff4f 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -1789,7 +1789,7 @@ class Client extends EventEmitter { * @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} + * @returns {Promise} 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, { diff --git a/lib/structures/Guild.js b/lib/structures/Guild.js index ee3e0d55f..1a2c3b4c0 100644 --- a/lib/structures/Guild.js +++ b/lib/structures/Guild.js @@ -831,7 +831,7 @@ class Guild extends Base { * 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} + * @returns {Promise} 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); From 65f669e86c4140db3c3f91730b2cf6b395c11bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conor=E2=84=A2?= Date: Sun, 21 Jan 2024 23:22:35 +0000 Subject: [PATCH 5/8] Im brain dead --- index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.d.ts b/index.d.ts index 222df58ba..59e80ea4d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -694,7 +694,7 @@ declare namespace Eris { large: boolean; maxMembers?: number; maxVideoChannelUsers?: number; - mfaLevel: MFALevel; + mfaLevel: Pick; name: string; /** @deprecated */ nsfw: boolean; @@ -2996,7 +2996,7 @@ declare namespace Eris { maxVideoChannelUsers?: number; memberCount: number; members: Collection; - mfaLevel: MFALevel; + mfaLevel: Pick; name: string; /** @deprecated */ nsfw: boolean; From ced824f0f8e27cd1e9ff1fbf908516c266e2b1e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conor=E2=84=A2?= Date: Sun, 21 Jan 2024 23:24:40 +0000 Subject: [PATCH 6/8] Fix --- lib/Client.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/Client.js b/lib/Client.js index af135ff4f..aeb223619 100644 --- a/lib/Client.js +++ b/lib/Client.js @@ -1797,7 +1797,6 @@ class Client extends EventEmitter { reason: reason }); } - /** * Edit a guild scheduled event From 7da87acfc5e9f5aa155135918f03d143ea9b608d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Conor=E2=84=A2?= Date: Sun, 21 Jan 2024 23:51:04 +0000 Subject: [PATCH 7/8] i sure hope this works... --- index.d.ts | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/index.d.ts b/index.d.ts index 59e80ea4d..3b70ded67 100644 --- a/index.d.ts +++ b/index.d.ts @@ -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; @@ -694,7 +695,7 @@ declare namespace Eris { large: boolean; maxMembers?: number; maxVideoChannelUsers?: number; - mfaLevel: Pick; + mfaLevel: MFALevel; name: string; /** @deprecated */ nsfw: boolean; @@ -1141,8 +1142,8 @@ declare namespace Eris { expireBehavior?: string; expireGracePeriod?: string; } - interface MFALevel { - level: Constants["MFALevels"][keyof Constants["MFALevels"]] + interface MFALevelResponse { + level: MFALevel } interface PruneMemberOptions extends GetPruneOptions { computePruneCount?: boolean; @@ -2643,7 +2644,7 @@ declare namespace Eris { ): Promise; editGuildIntegration(guildID: string, integrationID: string, options: IntegrationOptions): Promise; editGuildMember(guildID: string, memberID: string, options: MemberOptions, reason?: string): Promise; - editGuildMFALevel(guildID: string, level: Pick, reason?: string): Promise; + editGuildMFALevel(guildID: string, level: MFALevel, reason?: string): Promise; editGuildScheduledEvent(guildID: string, eventID: string, event: GuildScheduledEventEditOptions, reason?: string): Promise>; editGuildSticker(guildID: string, stickerID: string, options?: EditStickerOptions, reason?: string): Promise; editGuildTemplate(guildID: string, code: string, options: GuildTemplateOptions): Promise; @@ -2996,7 +2997,7 @@ declare namespace Eris { maxVideoChannelUsers?: number; memberCount: number; members: Collection; - mfaLevel: Pick; + mfaLevel: MFALevel; name: string; /** @deprecated */ nsfw: boolean; @@ -3070,7 +3071,7 @@ declare namespace Eris { editEmoji(emojiID: string, options: { name: string; roles?: string[] }, reason?: string): Promise; editIntegration(integrationID: string, options: IntegrationOptions): Promise; editMember(memberID: string, options: MemberOptions, reason?: string): Promise; - editMFALevel(level: Pick, reason?: string): Promise; + editMFALevel(level: MFALevel, reason?: string): Promise; /** @deprecated */ editNickname(nick: string): Promise; editRole(roleID: string, options: RoleOptions): Promise; From ada2e6367b7d667b22547823a3c9e337423df582 Mon Sep 17 00:00:00 2001 From: bsian03 Date: Mon, 22 Jan 2024 20:42:27 +0000 Subject: [PATCH 8/8] Update index.d.ts --- index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index 3b70ded67..858bb0f79 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1143,7 +1143,7 @@ declare namespace Eris { expireGracePeriod?: string; } interface MFALevelResponse { - level: MFALevel + level: MFALevel; } interface PruneMemberOptions extends GetPruneOptions { computePruneCount?: boolean;