diff --git a/src/structures/Guild.js b/src/structures/Guild.js index 61bb48f098cd..7dcbe855aec8 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -26,6 +26,7 @@ const { ExplicitContentFilterLevels, NSFWLevels, Status, + MFALevels, } = require('../util/Constants'); const DataResolver = require('../util/DataResolver'); const SystemChannelFlags = require('../util/SystemChannelFlags'); @@ -267,10 +268,10 @@ class Guild extends BaseGuild { this.explicitContentFilter = ExplicitContentFilterLevels[data.explicit_content_filter]; /** - * The required MFA level for the guild - * @type {number} + * The required MFA level for this guild + * @type {MFALevel} */ - this.mfaLevel = data.mfa_level; + this.mfaLevel = MFALevels[data.mfa_level]; /** * The timestamp the client user joined the guild at diff --git a/src/util/Constants.js b/src/util/Constants.js index 6204e707e1fb..a32f15299d34 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -863,6 +863,14 @@ exports.MessageComponentTypes = createEnum([null, 'ACTION_ROW', 'BUTTON']); */ exports.MessageButtonStyles = createEnum([null, 'PRIMARY', 'SECONDARY', 'SUCCESS', 'DANGER', 'LINK']); +/** + * The required MFA level for a guild + * * NONE + * * ELEVATED + * @typedef {string} MFALevel + */ +exports.MFALevels = createEnum(['NONE', 'ELEVATED']); + /** * NSFW level of a Guild * * DEFAULT diff --git a/typings/index.d.ts b/typings/index.d.ts index d6c5563244e1..23467f7bf0f5 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -53,6 +53,11 @@ declare enum MessageComponentTypes { BUTTON = 2, } +declare enum MFALevels { + NONE = 0, + ELEVATED = 1, +} + declare enum NSFWLevels { DEFAULT = 0, EXPLICIT = 1, @@ -681,6 +686,7 @@ declare module 'discord.js' { InteractionResponseTypes: typeof InteractionResponseTypes; MessageComponentTypes: typeof MessageComponentTypes; MessageButtonStyles: typeof MessageButtonStyles; + MFALevels: typeof MFALevels; NSFWLevels: typeof NSFWLevels; }; @@ -759,7 +765,7 @@ declare module 'discord.js' { public readonly me: GuildMember | null; public memberCount: number; public members: GuildMemberManager; - public mfaLevel: number; + public mfaLevel: MFALevel; public nsfwLevel: NSFWLevel; public ownerID: Snowflake; public preferredLocale: string; @@ -1655,8 +1661,14 @@ declare module 'discord.js' { public readonly ids: number[]; public mode: ShardingManagerMode; public parentPort: any | null; - public broadcastEval(fn: (client: Client, context: P) => T, { shard: undefined, context: P }?: BroadcastEvalOptions): Promise; - public broadcastEval(fn: (client: Client, context: P) => T, { shard: number, context: P }: BroadcastEvalOptions): Promise; + public broadcastEval( + fn: (client: Client, context: P) => T, + { shard: undefined, context: P }?: BroadcastEvalOptions, + ): Promise; + public broadcastEval( + fn: (client: Client, context: P) => T, + { shard: number, context: P }: BroadcastEvalOptions, + ): Promise; public fetchClientValues(prop: string): Promise; public fetchClientValues(prop: string, shard: number): Promise; public respawnAll(options?: { shardDelay?: number; respawnDelay?: number; timeout?: number }): Promise; @@ -1679,8 +1691,14 @@ declare module 'discord.js' { public totalShards: number | 'auto'; public shardList: number[] | 'auto'; public broadcast(message: any): Promise; - public broadcastEval(fn: (client: Client, context: P) => T, { shard: undefined, context: P }?: BroadcastEvalOptions): Promise; - public broadcastEval(fn: (client: Client, context: P) => T, { shard: number, context: P }: BroadcastEvalOptions): Promise; + public broadcastEval( + fn: (client: Client, context: P) => T, + { shard: undefined, context: P }?: BroadcastEvalOptions, + ): Promise; + public broadcastEval( + fn: (client: Client, context: P) => T, + { shard: number, context: P }: BroadcastEvalOptions, + ): Promise; public createShard(id: number): Shard; public fetchClientValues(prop: string): Promise; public fetchClientValues(prop: string, shard: number): Promise; @@ -1948,9 +1966,7 @@ declare module 'discord.js' { ): Promise; public fetchMessage(message: Snowflake, cache?: boolean): Promise; public send(options: string | APIMessage | (WebhookMessageOptions & { split?: false })): Promise; - public send( - options: APIMessage | (WebhookMessageOptions & { split: true | SplitOptions }), - ): Promise; + public send(options: APIMessage | (WebhookMessageOptions & { split: true | SplitOptions })): Promise; } export class WebSocketManager extends EventEmitter { @@ -2127,8 +2143,18 @@ declare module 'discord.js' { name: string, options: GuildCreateChannelOptions, ): Promise; - public fetch(id: Snowflake, cache?: boolean, force?: boolean): Promise; - public fetch(id?: Snowflake, cache?: boolean, force?: boolean): Promise>; + public fetch( + id: Snowflake, + cache?: boolean, + force?: boolean, + ): Promise; + public fetch( + id?: Snowflake, + cache?: boolean, + force?: boolean, + ): Promise< + Collection + >; } export class GuildEmojiManager extends BaseGuildEmojiManager { @@ -3370,6 +3396,8 @@ declare module 'discord.js' { | 'REPLY' | 'APPLICATION_COMMAND'; + type MFALevel = keyof typeof MFALevels; + type NSFWLevel = keyof typeof NSFWLevels; interface OverwriteData {