Skip to content

Commit

Permalink
feat(Guild): add enum for mfa_level (#5797)
Browse files Browse the repository at this point in the history
  • Loading branch information
iShibi committed Jun 10, 2021
1 parent 2f5424b commit ffabec3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/structures/Guild.js
Expand Up @@ -25,6 +25,7 @@ const {
ExplicitContentFilterLevels,
NSFWLevels,
Status,
MFALevels,
} = require('../util/Constants');
const DataResolver = require('../util/DataResolver');
const SystemChannelFlags = require('../util/SystemChannelFlags');
Expand Down Expand Up @@ -260,10 +261,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
Expand Down
8 changes: 8 additions & 0 deletions src/util/Constants.js
Expand Up @@ -867,6 +867,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
Expand Down
10 changes: 9 additions & 1 deletion typings/index.d.ts
Expand Up @@ -53,6 +53,11 @@ declare enum MessageComponentTypes {
BUTTON = 2,
}

declare enum MFALevels {
NONE = 0,
ELEVATED = 1,
}

declare enum NSFWLevels {
DEFAULT = 0,
EXPLICIT = 1,
Expand Down Expand Up @@ -681,6 +686,7 @@ declare module 'discord.js' {
InteractionResponseTypes: typeof InteractionResponseTypes;
MessageComponentTypes: typeof MessageComponentTypes;
MessageButtonStyles: typeof MessageButtonStyles;
MFALevels: typeof MFALevels;
NSFWLevels: typeof NSFWLevels;
};

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -3388,6 +3394,8 @@ declare module 'discord.js' {
| 'REPLY'
| 'APPLICATION_COMMAND';

type MFALevel = keyof typeof MFALevels;

type NSFWLevel = keyof typeof NSFWLevels;

interface OverwriteData {
Expand Down

0 comments on commit ffabec3

Please sign in to comment.