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