Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Guild): add enum for mfa_level #5797

Merged
merged 1 commit into from
Jun 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const {
ExplicitContentFilterLevels,
NSFWLevels,
Status,
MFALevels,
} = require('../util/Constants');
const DataResolver = require('../util/DataResolver');
const SystemChannelFlags = require('../util/SystemChannelFlags');
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions src/util/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
48 changes: 38 additions & 10 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
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 @@ -1655,8 +1661,14 @@ declare module 'discord.js' {
public readonly ids: number[];
public mode: ShardingManagerMode;
public parentPort: any | null;
public broadcastEval<T, P>(fn: (client: Client, context: P) => T, { shard: undefined, context: P }?: BroadcastEvalOptions): Promise<T[]>;
public broadcastEval<T, P>(fn: (client: Client, context: P) => T, { shard: number, context: P }: BroadcastEvalOptions): Promise<T>;
public broadcastEval<T, P>(
fn: (client: Client, context: P) => T,
{ shard: undefined, context: P }?: BroadcastEvalOptions,
): Promise<T[]>;
public broadcastEval<T, P>(
fn: (client: Client, context: P) => T,
{ shard: number, context: P }: BroadcastEvalOptions,
): Promise<T>;
public fetchClientValues(prop: string): Promise<any[]>;
public fetchClientValues(prop: string, shard: number): Promise<any>;
public respawnAll(options?: { shardDelay?: number; respawnDelay?: number; timeout?: number }): Promise<void>;
Expand All @@ -1679,8 +1691,14 @@ declare module 'discord.js' {
public totalShards: number | 'auto';
public shardList: number[] | 'auto';
public broadcast(message: any): Promise<Shard[]>;
public broadcastEval<T, P>(fn: (client: Client, context: P) => T, { shard: undefined, context: P }?: BroadcastEvalOptions): Promise<T[]>;
public broadcastEval<T, P>(fn: (client: Client, context: P) => T, { shard: number, context: P }: BroadcastEvalOptions): Promise<T>;
public broadcastEval<T, P>(
fn: (client: Client, context: P) => T,
{ shard: undefined, context: P }?: BroadcastEvalOptions,
): Promise<T[]>;
public broadcastEval<T, P>(
fn: (client: Client, context: P) => T,
{ shard: number, context: P }: BroadcastEvalOptions,
): Promise<T>;
public createShard(id: number): Shard;
public fetchClientValues(prop: string): Promise<any[]>;
public fetchClientValues(prop: string, shard: number): Promise<any>;
Expand Down Expand Up @@ -1948,9 +1966,7 @@ declare module 'discord.js' {
): Promise<RawMessage>;
public fetchMessage(message: Snowflake, cache?: boolean): Promise<RawMessage>;
public send(options: string | APIMessage | (WebhookMessageOptions & { split?: false })): Promise<RawMessage>;
public send(
options: APIMessage | (WebhookMessageOptions & { split: true | SplitOptions }),
): Promise<RawMessage[]>;
public send(options: APIMessage | (WebhookMessageOptions & { split: true | SplitOptions })): Promise<RawMessage[]>;
}

export class WebSocketManager extends EventEmitter {
Expand Down Expand Up @@ -2127,8 +2143,18 @@ declare module 'discord.js' {
name: string,
options: GuildCreateChannelOptions,
): Promise<TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StoreChannel | StageChannel>;
public fetch(id: Snowflake, cache?: boolean, force?: boolean): Promise<TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StoreChannel | StageChannel | null>;
public fetch(id?: Snowflake, cache?: boolean, force?: boolean): Promise<Collection<Snowflake, TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StoreChannel | StageChannel>>;
public fetch(
id: Snowflake,
cache?: boolean,
force?: boolean,
): Promise<TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StoreChannel | StageChannel | null>;
public fetch(
id?: Snowflake,
cache?: boolean,
force?: boolean,
): Promise<
Collection<Snowflake, TextChannel | VoiceChannel | CategoryChannel | NewsChannel | StoreChannel | StageChannel>
>;
}

export class GuildEmojiManager extends BaseGuildEmojiManager {
Expand Down Expand Up @@ -3370,6 +3396,8 @@ declare module 'discord.js' {
| 'REPLY'
| 'APPLICATION_COMMAND';

type MFALevel = keyof typeof MFALevels;

type NSFWLevel = keyof typeof NSFWLevels;

interface OverwriteData {
Expand Down