mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-07-05 18:27:18 +00:00
refactor: no more enums
This commit is contained in:
parent
f607ad424b
commit
77b54f6505
12 changed files with 115 additions and 92 deletions
|
@ -1,18 +1,20 @@
|
|||
import { Guild } from "discord.js";
|
||||
|
||||
export enum ERRORS {
|
||||
NO_MUTE_ROLE_IN_CONFIG = 1,
|
||||
UNKNOWN_NOTE_CASE,
|
||||
INVALID_EMOJI,
|
||||
NO_USER_NOTIFICATION_CHANNEL,
|
||||
INVALID_USER_NOTIFICATION_CHANNEL,
|
||||
INVALID_USER,
|
||||
INVALID_MUTE_ROLE_ID,
|
||||
MUTE_ROLE_ABOVE_ZEP,
|
||||
USER_ABOVE_ZEP,
|
||||
USER_NOT_MODERATABLE,
|
||||
TEMPLATE_PARSE_ERROR,
|
||||
}
|
||||
export const ERRORS = {
|
||||
NO_MUTE_ROLE_IN_CONFIG: 1,
|
||||
UNKNOWN_NOTE_CASE: 2,
|
||||
INVALID_EMOJI: 3,
|
||||
NO_USER_NOTIFICATION_CHANNEL: 4,
|
||||
INVALID_USER_NOTIFICATION_CHANNEL: 5,
|
||||
INVALID_USER: 6,
|
||||
INVALID_MUTE_ROLE_ID: 7,
|
||||
MUTE_ROLE_ABOVE_ZEP: 8,
|
||||
USER_ABOVE_ZEP: 9,
|
||||
USER_NOT_MODERATABLE: 10,
|
||||
TEMPLATE_PARSE_ERROR: 11,
|
||||
} as const;
|
||||
|
||||
export type ERRORS = typeof ERRORS[keyof typeof ERRORS];
|
||||
|
||||
export const RECOVERABLE_PLUGIN_ERROR_MESSAGES = {
|
||||
[ERRORS.NO_MUTE_ROLE_IN_CONFIG]: "No mute role specified in config",
|
||||
|
|
|
@ -6,10 +6,12 @@ import { AuditLogEventTypes } from "./apiAuditLogTypes.js";
|
|||
import { dataSource } from "./dataSource.js";
|
||||
import { ApiPermissionAssignment } from "./entities/ApiPermissionAssignment.js";
|
||||
|
||||
export enum ApiPermissionTypes {
|
||||
User = "USER",
|
||||
Role = "ROLE",
|
||||
}
|
||||
export const ApiPermissionTypes = {
|
||||
User: "USER",
|
||||
Role: "ROLE",
|
||||
} as const;
|
||||
|
||||
export type ApiPermissionTypes = (typeof ApiPermissionTypes)[keyof typeof ApiPermissionTypes];
|
||||
|
||||
export class ApiPermissionAssignments extends BaseRepository {
|
||||
private apiPermissions: Repository<ApiPermissionAssignment>;
|
||||
|
|
|
@ -1,14 +1,16 @@
|
|||
export enum CaseTypes {
|
||||
Ban = 1,
|
||||
Unban,
|
||||
Note,
|
||||
Warn,
|
||||
Kick,
|
||||
Mute,
|
||||
Unmute,
|
||||
Deleted,
|
||||
Softban,
|
||||
}
|
||||
export const CaseTypes = {
|
||||
Ban: 1,
|
||||
Unban: 2,
|
||||
Note: 3,
|
||||
Warn: 4,
|
||||
Kick: 5,
|
||||
Mute: 6,
|
||||
Unmute: 7,
|
||||
Deleted: 8,
|
||||
Softban: 9,
|
||||
} as const;
|
||||
|
||||
export type CaseTypes = typeof CaseTypes[keyof typeof CaseTypes];
|
||||
|
||||
export const CaseNameToType = {
|
||||
ban: CaseTypes.Ban,
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
export enum MuteTypes {
|
||||
Role = 1,
|
||||
Timeout = 2,
|
||||
}
|
||||
export const MuteTypes = {
|
||||
Role: 1,
|
||||
Timeout: 2,
|
||||
} as const;
|
||||
|
||||
export type MuteTypes = typeof MuteTypes[keyof typeof MuteTypes];
|
||||
|
|
|
@ -5,19 +5,21 @@ export const RECENT_SPAM_EXPIRY_TIME = 10 * SECONDS;
|
|||
export const RECENT_ACTION_EXPIRY_TIME = 5 * MINUTES;
|
||||
export const RECENT_NICKNAME_CHANGE_EXPIRY_TIME = 5 * MINUTES;
|
||||
|
||||
export enum RecentActionType {
|
||||
Message = 1,
|
||||
Mention,
|
||||
Link,
|
||||
Attachment,
|
||||
Emoji,
|
||||
Line,
|
||||
Character,
|
||||
VoiceChannelMove,
|
||||
MemberJoin,
|
||||
Sticker,
|
||||
MemberLeave,
|
||||
ThreadCreate,
|
||||
}
|
||||
export const RecentActionType = {
|
||||
Message: 1,
|
||||
Mention: 2,
|
||||
Link: 3,
|
||||
Attachment: 4,
|
||||
Emoji: 5,
|
||||
Line: 6,
|
||||
Character: 7,
|
||||
VoiceChannelMove: 8,
|
||||
MemberJoin: 9,
|
||||
Sticker: 10,
|
||||
MemberLeave: 11,
|
||||
ThreadCreate: 12,
|
||||
} as const;
|
||||
|
||||
export type RecentActionType = typeof RecentActionType[keyof typeof RecentActionType];
|
||||
|
||||
export const zNotify = z.union([z.literal("dm"), z.literal("channel")]);
|
||||
|
|
|
@ -68,7 +68,7 @@ export async function getCaseEmbed(
|
|||
embed.title += " (hidden)";
|
||||
}
|
||||
|
||||
embed.color = getCaseColor(pluginData, theCase.type);
|
||||
embed.color = getCaseColor(pluginData, theCase.type as CaseTypes);
|
||||
|
||||
if (theCase.notes.length) {
|
||||
for (const note of theCase.notes) {
|
||||
|
|
|
@ -7,6 +7,7 @@ import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js";
|
|||
import { caseAbbreviations } from "../caseAbbreviations.js";
|
||||
import { CasesPluginType } from "../types.js";
|
||||
import { getCaseIcon } from "./getCaseIcon.js";
|
||||
import type { CaseTypes } from "../../../data/CaseTypes.js";
|
||||
|
||||
const CASE_SUMMARY_REASON_MAX_LENGTH = 300;
|
||||
const INCLUDE_MORE_NOTES_THRESHOLD = 20;
|
||||
|
@ -52,7 +53,7 @@ export async function getCaseSummary(
|
|||
? moment.utc().to(timestamp)
|
||||
: timestampWithTz.format(timeAndDate.getDateFormat("date"));
|
||||
|
||||
const icon = getCaseIcon(pluginData, theCase.type);
|
||||
const icon = getCaseIcon(pluginData, theCase.type as CaseTypes);
|
||||
|
||||
let caseTitle = `\`#${theCase.case_number}\``;
|
||||
if (withLinks && theCase.log_message_id) {
|
||||
|
|
|
@ -15,23 +15,27 @@ export interface ContextMenuPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export const enum ModMenuActionType {
|
||||
PAGE = "page",
|
||||
NOTE = "note",
|
||||
WARN = "warn",
|
||||
CLEAN = "clean",
|
||||
MUTE = "mute",
|
||||
BAN = "ban",
|
||||
}
|
||||
export const ModMenuActionType = {
|
||||
PAGE: "page",
|
||||
NOTE: "note",
|
||||
WARN: "warn",
|
||||
CLEAN: "clean",
|
||||
MUTE: "mute",
|
||||
BAN: "ban",
|
||||
} as const;
|
||||
|
||||
export const enum ModMenuNavigationType {
|
||||
FIRST = "first",
|
||||
PREV = "prev",
|
||||
NEXT = "next",
|
||||
LAST = "last",
|
||||
INFO = "info",
|
||||
CASES = "cases",
|
||||
}
|
||||
export type ModMenuActionType = typeof ModMenuActionType[keyof typeof ModMenuActionType];
|
||||
|
||||
export const ModMenuNavigationType = {
|
||||
FIRST: "first",
|
||||
PREV: "prev",
|
||||
NEXT: "next",
|
||||
LAST: "last",
|
||||
INFO: "info",
|
||||
CASES: "cases",
|
||||
} as const;
|
||||
|
||||
export type ModMenuNavigationType = typeof ModMenuNavigationType[keyof typeof ModMenuNavigationType];
|
||||
|
||||
export interface ModMenuActionOpts {
|
||||
action: ModMenuActionType;
|
||||
|
|
|
@ -112,7 +112,9 @@ export async function actualMassUnbanCmd(
|
|||
}
|
||||
}
|
||||
|
||||
enum UnbanFailReasons {
|
||||
NOT_BANNED = "Not banned",
|
||||
UNBAN_FAILED = "Unban failed",
|
||||
}
|
||||
const UnbanFailReasons = {
|
||||
NOT_BANNED: "Not banned",
|
||||
UNBAN_FAILED: "Unban failed",
|
||||
} as const;
|
||||
|
||||
type UnbanFailReasons = typeof UnbanFailReasons[keyof typeof UnbanFailReasons];
|
||||
|
|
|
@ -102,11 +102,13 @@ export interface ModActionsPluginType extends BasePluginType {
|
|||
};
|
||||
}
|
||||
|
||||
export enum IgnoredEventType {
|
||||
Ban = 1,
|
||||
Unban,
|
||||
Kick,
|
||||
}
|
||||
export const IgnoredEventType = {
|
||||
Ban: 1,
|
||||
Unban: 2,
|
||||
Kick: 3,
|
||||
} as const;
|
||||
|
||||
export type IgnoredEventType = typeof IgnoredEventType[keyof typeof IgnoredEventType];
|
||||
|
||||
export interface IIgnoredEvent {
|
||||
type: IgnoredEventType;
|
||||
|
|
|
@ -30,17 +30,19 @@ export const zSpamConfig = z.strictObject({
|
|||
max_voice_moves: zBaseSingleSpamConfig.nullable().default(null),
|
||||
});
|
||||
|
||||
export enum RecentActionType {
|
||||
Message = 1,
|
||||
Mention,
|
||||
Link,
|
||||
Attachment,
|
||||
Emoji,
|
||||
Newline,
|
||||
Censor,
|
||||
Character,
|
||||
VoiceChannelMove,
|
||||
}
|
||||
export const RecentActionType = {
|
||||
Message: 1,
|
||||
Mention: 2,
|
||||
Link: 3,
|
||||
Attachment: 4,
|
||||
Emoji: 5,
|
||||
Newline: 6,
|
||||
Censor: 7,
|
||||
Character: 8,
|
||||
VoiceChannelMove: 9,
|
||||
} as const;
|
||||
|
||||
export type RecentActionType = typeof RecentActionType[keyof typeof RecentActionType];
|
||||
|
||||
export interface IRecentAction<T> {
|
||||
type: RecentActionType;
|
||||
|
|
|
@ -36,10 +36,12 @@ const SEARCH_RESULTS_PER_PAGE = 15;
|
|||
const SEARCH_ID_RESULTS_PER_PAGE = 50;
|
||||
const SEARCH_EXPORT_LIMIT = 1_000_000;
|
||||
|
||||
export enum SearchType {
|
||||
MemberSearch,
|
||||
BanSearch,
|
||||
}
|
||||
export const SearchType = {
|
||||
MemberSearch: 0,
|
||||
BanSearch: 1,
|
||||
} as const;
|
||||
|
||||
export type SearchType = typeof SearchType[keyof typeof SearchType];
|
||||
|
||||
class SearchError extends Error {}
|
||||
|
||||
|
@ -72,13 +74,13 @@ function getOptimizedRegExpRunner(pluginData: GuildPluginData<UtilityPluginType>
|
|||
export async function displaySearch(
|
||||
pluginData: GuildPluginData<UtilityPluginType>,
|
||||
args: MemberSearchParams,
|
||||
searchType: SearchType.MemberSearch,
|
||||
searchType: (typeof SearchType)["MemberSearch"],
|
||||
msg: OmitPartialGroupDMChannel<Message>,
|
||||
);
|
||||
export async function displaySearch(
|
||||
pluginData: GuildPluginData<UtilityPluginType>,
|
||||
args: BanSearchParams,
|
||||
searchType: SearchType.BanSearch,
|
||||
searchType: (typeof SearchType)["BanSearch"],
|
||||
msg: OmitPartialGroupDMChannel<Message>,
|
||||
);
|
||||
export async function displaySearch(
|
||||
|
@ -239,13 +241,13 @@ export async function displaySearch(
|
|||
export async function archiveSearch(
|
||||
pluginData: GuildPluginData<UtilityPluginType>,
|
||||
args: MemberSearchParams,
|
||||
searchType: SearchType.MemberSearch,
|
||||
searchType: (typeof SearchType)["MemberSearch"],
|
||||
msg: OmitPartialGroupDMChannel<Message>,
|
||||
);
|
||||
export async function archiveSearch(
|
||||
pluginData: GuildPluginData<UtilityPluginType>,
|
||||
args: BanSearchParams,
|
||||
searchType: SearchType.BanSearch,
|
||||
searchType: (typeof SearchType)["BanSearch"],
|
||||
msg: OmitPartialGroupDMChannel<Message>,
|
||||
);
|
||||
export async function archiveSearch(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue