diff --git a/backend/src/RegExpRunner.ts b/backend/src/RegExpRunner.ts index ea37fe037..41577001b 100644 --- a/backend/src/RegExpRunner.ts +++ b/backend/src/RegExpRunner.ts @@ -9,7 +9,10 @@ const isTimeoutError = (a): a is TimeoutError => { }; export class RegExpTimeoutError extends Error { - constructor(message: string, public elapsedTimeMs: number) { + constructor( + message: string, + public elapsedTimeMs: number, + ) { super(message); } } diff --git a/backend/src/api/docs.ts b/backend/src/api/docs.ts index 59aef88b9..7dba56768 100644 --- a/backend/src/api/docs.ts +++ b/backend/src/api/docs.ts @@ -1,10 +1,10 @@ import express from "express"; import z from "zod/v4"; +import { $ZodPipeDef } from "zod/v4/core"; import { availableGuildPlugins } from "../plugins/availablePlugins.js"; import { ZeppelinGuildPluginInfo } from "../types.js"; import { indentLines } from "../utils.js"; import { notFound } from "./responses.js"; -import { $ZodPipeDef } from "zod/v4/core"; function isZodObject(schema: z.ZodType): schema is z.ZodObject { return schema.def.type === "object"; diff --git a/backend/src/configValidator.ts b/backend/src/configValidator.ts index e66f97c59..1eef82dcc 100644 --- a/backend/src/configValidator.ts +++ b/backend/src/configValidator.ts @@ -28,15 +28,12 @@ export async function validateGuildConfig(config: any): Promise { } const plugin = pluginNameToPlugin.get(pluginName)!; - const configManager = new PluginConfigManager( - pluginOptions, - { - configSchema: plugin.configSchema, - defaultOverrides: plugin.defaultOverrides ?? [], - levels: {}, - customOverrideCriteriaFunctions: plugin.customOverrideCriteriaFunctions, - }, - ); + const configManager = new PluginConfigManager(pluginOptions, { + configSchema: plugin.configSchema, + defaultOverrides: plugin.defaultOverrides ?? [], + levels: {}, + customOverrideCriteriaFunctions: plugin.customOverrideCriteriaFunctions, + }); try { await configManager.init(); diff --git a/backend/src/data/FishFish.ts b/backend/src/data/FishFish.ts index 7f502e5de..2cf0cccc2 100644 --- a/backend/src/data/FishFish.ts +++ b/backend/src/data/FishFish.ts @@ -59,9 +59,12 @@ async function getSessionToken(): Promise { } const timeUntilExpiry = Date.now() - parseResult.data.expires * 1000; - setTimeout(() => { - sessionTokenPromise = null; - }, timeUntilExpiry - 1 * MINUTES); // Subtract a minute to ensure we refresh before expiry + setTimeout( + () => { + sessionTokenPromise = null; + }, + timeUntilExpiry - 1 * MINUTES, + ); // Subtract a minute to ensure we refresh before expiry return parseResult.data.token; })(); diff --git a/backend/src/data/GuildLogs.ts b/backend/src/data/GuildLogs.ts index dc4837eef..40c7138ef 100644 --- a/backend/src/data/GuildLogs.ts +++ b/backend/src/data/GuildLogs.ts @@ -40,9 +40,12 @@ export class GuildLogs extends events.EventEmitter { this.ignoredLogs.push({ type, ignoreId }); // Clear after expiry (15sec by default) - setTimeout(() => { - this.clearIgnoredLog(type, ignoreId); - }, timeout || 1000 * 15); + setTimeout( + () => { + this.clearIgnoredLog(type, ignoreId); + }, + timeout || 1000 * 15, + ); } isLogIgnored(type: keyof typeof LogType, ignoreId: any) { diff --git a/backend/src/exportSchemas.ts b/backend/src/exportSchemas.ts index 003a1216a..865ea773e 100644 --- a/backend/src/exportSchemas.ts +++ b/backend/src/exportSchemas.ts @@ -34,22 +34,24 @@ const basePluginOverrideCriteriaSchema = z.strictObject({ extra: z.any().optional(), }); -const pluginOverrideCriteriaSchema = basePluginOverrideCriteriaSchema.extend({ - get zzz_dummy_property_do_not_use() { - return pluginOverrideCriteriaSchema.optional(); - }, - get all() { - return z.array(pluginOverrideCriteriaSchema).optional(); - }, - get any() { - return z.array(pluginOverrideCriteriaSchema).optional(); - }, - get not() { - return pluginOverrideCriteriaSchema.optional(); - }, -}).meta({ - id: "overrideCriteria", -}); +const pluginOverrideCriteriaSchema = basePluginOverrideCriteriaSchema + .extend({ + get zzz_dummy_property_do_not_use() { + return pluginOverrideCriteriaSchema.optional(); + }, + get all() { + return z.array(pluginOverrideCriteriaSchema).optional(); + }, + get any() { + return z.array(pluginOverrideCriteriaSchema).optional(); + }, + get not() { + return pluginOverrideCriteriaSchema.optional(); + }, + }) + .meta({ + id: "overrideCriteria", + }); const outputPath = process.argv[2]; if (!outputPath) { diff --git a/backend/src/index.ts b/backend/src/index.ts index 6f9e8771b..900d4d8b3 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -199,14 +199,17 @@ setInterval(() => { avgCount++; lastCheck = now; }, 500); -setInterval(() => { - const avgBlocking = avgTotal / (avgCount || 1); - // FIXME: Debug - // tslint:disable-next-line:no-console - console.log(`Average blocking in the last 5min: ${avgBlocking / avgTotal}ms`); - avgTotal = 0; - avgCount = 0; -}, 5 * 60 * 1000); +setInterval( + () => { + const avgBlocking = avgTotal / (avgCount || 1); + // FIXME: Debug + // tslint:disable-next-line:no-console + console.log(`Average blocking in the last 5min: ${avgBlocking / avgTotal}ms`); + avgTotal = 0; + avgCount = 0; + }, + 5 * 60 * 1000, +); if (env.DEBUG) { logger.info("NOTE: Bot started in DEBUG mode"); @@ -335,7 +338,7 @@ connect().then(async () => { if (loaded.success_emoji || loaded.error_emoji) { const deprecatedKeys = [] as string[]; - const exampleConfig = `plugins:\n common:\n config:\n success_emoji: "👍"\n error_emoji: "👎"`; + // const exampleConfig = `plugins:\n common:\n config:\n success_emoji: "👍"\n error_emoji: "👎"`; if (loaded.success_emoji) { deprecatedKeys.push("success_emoji"); diff --git a/backend/src/plugins/Automod/actions/changePerms.ts b/backend/src/plugins/Automod/actions/changePerms.ts index e70bbb056..0fa7968c6 100644 --- a/backend/src/plugins/Automod/actions/changePerms.ts +++ b/backend/src/plugins/Automod/actions/changePerms.ts @@ -65,10 +65,13 @@ const permissionNames = keys(PermissionsBitField.Flags) as U.ListOf; const allPermissionNames = [...permissionNames, ...legacyPermissionNames] as const; -const permissionTypeMap = allPermissionNames.reduce((map, permName) => { - map[permName] = z.boolean().nullable(); - return map; -}, {} as Record>); +const permissionTypeMap = allPermissionNames.reduce( + (map, permName) => { + map[permName] = z.boolean().nullable(); + return map; + }, + {} as Record<(typeof allPermissionNames)[number], z.ZodNullable>, +); const zPermissionsMap = z.strictObject(permissionTypeMap); export const ChangePermsAction = automodAction({ diff --git a/backend/src/plugins/Automod/commands/DebugAutomodCmd.ts b/backend/src/plugins/Automod/commands/DebugAutomodCmd.ts index 63942b9a3..f4430a699 100644 --- a/backend/src/plugins/Automod/commands/DebugAutomodCmd.ts +++ b/backend/src/plugins/Automod/commands/DebugAutomodCmd.ts @@ -10,7 +10,7 @@ import { getOrFetchUser } from "../../../utils/getOrFetchUser.js"; export const DebugAutomodCmd = guildPluginMessageCommand()({ trigger: "debug_automod", permission: "can_debug_automod", - + signature: { messageId: ct.string(), }, diff --git a/backend/src/plugins/Automod/functions/runAutomod.ts b/backend/src/plugins/Automod/functions/runAutomod.ts index e5bed2eae..60095b076 100644 --- a/backend/src/plugins/Automod/functions/runAutomod.ts +++ b/backend/src/plugins/Automod/functions/runAutomod.ts @@ -32,7 +32,7 @@ interface RuleResultOutcomeSuccess { interface RuleResultOutcomeFailure { success: false; - reason: typeof ruleFailReason[keyof typeof ruleFailReason]; + reason: (typeof ruleFailReason)[keyof typeof ruleFailReason]; } type RuleResultOutcome = RuleResultOutcomeSuccess | RuleResultOutcomeFailure; @@ -48,7 +48,11 @@ interface AutomodRunResult { rulesChecked: RuleResult[]; } -export async function runAutomod(pluginData: GuildPluginData, context: AutomodContext, dryRun: boolean = false): Promise { +export async function runAutomod( + pluginData: GuildPluginData, + context: AutomodContext, + dryRun = false, +): Promise { const userId = context.user?.id || context.member?.id || context.message?.user_id; const user = context.user || (userId && pluginData.client.users!.cache.get(userId as Snowflake)); const member = context.member || (userId && pluginData.guild.members.cache.get(userId as Snowflake)) || null; diff --git a/backend/src/plugins/Automod/triggers/matchInvites.ts b/backend/src/plugins/Automod/triggers/matchInvites.ts index cf77fe7e9..b23b0c0dd 100644 --- a/backend/src/plugins/Automod/triggers/matchInvites.ts +++ b/backend/src/plugins/Automod/triggers/matchInvites.ts @@ -15,8 +15,16 @@ const configSchema = z.strictObject({ exclude_guilds: z.array(zSnowflake).max(255).optional(), include_invite_codes: z.array(z.string().max(32)).max(255).optional(), exclude_invite_codes: z.array(z.string().max(32)).max(255).optional(), - include_custom_invite_codes: z.array(z.string().max(32)).max(255).transform(arr => arr.map(str => str.toLowerCase())).optional(), - exclude_custom_invite_codes: z.array(z.string().max(32)).max(255).transform(arr => arr.map(str => str.toLowerCase())).optional(), + include_custom_invite_codes: z + .array(z.string().max(32)) + .max(255) + .transform((arr) => arr.map((str) => str.toLowerCase())) + .optional(), + exclude_custom_invite_codes: z + .array(z.string().max(32)) + .max(255) + .transform((arr) => arr.map((str) => str.toLowerCase())) + .optional(), allow_group_dm_invites: z.boolean().default(false), match_messages: z.boolean().default(true), match_embeds: z.boolean().default(false), diff --git a/backend/src/plugins/Automod/triggers/matchLinks.ts b/backend/src/plugins/Automod/triggers/matchLinks.ts index 9955b3104..b18b00c07 100644 --- a/backend/src/plugins/Automod/triggers/matchLinks.ts +++ b/backend/src/plugins/Automod/triggers/matchLinks.ts @@ -73,7 +73,10 @@ export const MatchLinksTrigger = automodTrigger()({ if (trigger.exclude_regex) { if (!regexCache.has(trigger.exclude_regex)) { - const toCache = mergeRegexes(trigger.exclude_regex.map(pattern => inputPatternToRegExp(pattern)), "i"); + const toCache = mergeRegexes( + trigger.exclude_regex.map((pattern) => inputPatternToRegExp(pattern)), + "i", + ); regexCache.set(trigger.exclude_regex, toCache); } const regexes = regexCache.get(trigger.exclude_regex)!; @@ -88,7 +91,10 @@ export const MatchLinksTrigger = automodTrigger()({ if (trigger.include_regex) { if (!regexCache.has(trigger.include_regex)) { - const toCache = mergeRegexes(trigger.include_regex.map(pattern => inputPatternToRegExp(pattern)), "i"); + const toCache = mergeRegexes( + trigger.include_regex.map((pattern) => inputPatternToRegExp(pattern)), + "i", + ); regexCache.set(trigger.include_regex, toCache); } const regexes = regexCache.get(trigger.include_regex)!; diff --git a/backend/src/plugins/Automod/triggers/matchRegex.ts b/backend/src/plugins/Automod/triggers/matchRegex.ts index 4298cfc36..8d2741cb1 100644 --- a/backend/src/plugins/Automod/triggers/matchRegex.ts +++ b/backend/src/plugins/Automod/triggers/matchRegex.ts @@ -38,7 +38,10 @@ export const MatchRegexTrigger = automodTrigger()({ if (!regexCache.has(trigger)) { const flags = trigger.case_sensitive ? "" : "i"; - const toCache = mergeRegexes(trigger.patterns.map(pattern => inputPatternToRegExp(pattern)), flags); + const toCache = mergeRegexes( + trigger.patterns.map((pattern) => inputPatternToRegExp(pattern)), + flags, + ); regexCache.set(trigger, toCache); } const regexes = regexCache.get(trigger)!; diff --git a/backend/src/plugins/Automod/triggers/matchWords.ts b/backend/src/plugins/Automod/triggers/matchWords.ts index 0c324e53b..332d5c486 100644 --- a/backend/src/plugins/Automod/triggers/matchWords.ts +++ b/backend/src/plugins/Automod/triggers/matchWords.ts @@ -44,9 +44,7 @@ export const MatchWordsTrigger = automodTrigger()({ let pattern; if (trigger.loose_matching) { - pattern = [...word] - .map((c) => escapeStringRegexp(c)) - .join(`[\\s\\-_.,!?]{0,${looseMatchingThreshold}}`); + pattern = [...word].map((c) => escapeStringRegexp(c)).join(`[\\s\\-_.,!?]{0,${looseMatchingThreshold}}`); } else { pattern = escapeStringRegexp(word); } @@ -62,10 +60,7 @@ export const MatchWordsTrigger = automodTrigger()({ return pattern; }); - const mergedRegex = new RegExp( - patterns.map((p) => `(${p})`).join("|"), - trigger.case_sensitive ? "" : "i" - ); + const mergedRegex = new RegExp(patterns.map((p) => `(${p})`).join("|"), trigger.case_sensitive ? "" : "i"); regexCache.set(trigger, [mergedRegex]); } @@ -84,7 +79,7 @@ export const MatchWordsTrigger = automodTrigger()({ for (const regex of regexes) { const match = regex.exec(str); if (match) { - const matchedWordIndex = match.slice(1).findIndex(group => group !== undefined); + const matchedWordIndex = match.slice(1).findIndex((group) => group !== undefined); const matchedWord = trigger.words[matchedWordIndex]; return { diff --git a/backend/src/plugins/Cases/functions/getCaseSummary.ts b/backend/src/plugins/Cases/functions/getCaseSummary.ts index 79f8687a1..a16e51841 100644 --- a/backend/src/plugins/Cases/functions/getCaseSummary.ts +++ b/backend/src/plugins/Cases/functions/getCaseSummary.ts @@ -2,7 +2,7 @@ import { GuildPluginData } from "knub"; import { splitMessageIntoChunks } from "knub/helpers"; import moment from "moment-timezone"; import { Case } from "../../../data/entities/Case.js"; -import { convertDelayStringToMS, DBDateFormat, disableLinkPreviews, messageLink } from "../../../utils.js"; +import { convertDelayStringToMS, DBDateFormat, messageLink } from "../../../utils.js"; import { TimeAndDatePlugin } from "../../TimeAndDate/TimeAndDatePlugin.js"; import { caseAbbreviations } from "../caseAbbreviations.js"; import { CasesPluginType } from "../types.js"; diff --git a/backend/src/plugins/Cases/types.ts b/backend/src/plugins/Cases/types.ts index 46519ac41..3ec47bba9 100644 --- a/backend/src/plugins/Cases/types.ts +++ b/backend/src/plugins/Cases/types.ts @@ -10,15 +10,21 @@ import { zColor } from "../../utils/zColor.js"; const caseKeys = keys(CaseNameToType) as U.ListOf; -const caseColorsTypeMap = caseKeys.reduce((map, key) => { - map[key] = zColor; - return map; -}, {} as Record); +const caseColorsTypeMap = caseKeys.reduce( + (map, key) => { + map[key] = zColor; + return map; + }, + {} as Record<(typeof caseKeys)[number], typeof zColor>, +); -const caseIconsTypeMap = caseKeys.reduce((map, key) => { - map[key] = zBoundedCharacters(0, 100); - return map; -}, {} as Record); +const caseIconsTypeMap = caseKeys.reduce( + (map, key) => { + map[key] = zBoundedCharacters(0, 100); + return map; + }, + {} as Record<(typeof caseKeys)[number], z.ZodString>, +); export const zCasesConfig = z.strictObject({ log_automatic_actions: z.boolean().default(true), diff --git a/backend/src/plugins/Common/CommonPlugin.ts b/backend/src/plugins/Common/CommonPlugin.ts index 7e57fc291..149b9d4c4 100644 --- a/backend/src/plugins/Common/CommonPlugin.ts +++ b/backend/src/plugins/Common/CommonPlugin.ts @@ -49,7 +49,7 @@ export const CommonPlugin = guildPlugin()({ storeAttachmentsAsMessage: async (attachments: Attachment[], backupChannel?: TextBasedChannel | null) => { const attachmentChannelId = pluginData.config.get().attachment_storing_channel; const channel = attachmentChannelId - ? (pluginData.guild.channels.cache.get(attachmentChannelId) as TextBasedChannel) ?? backupChannel + ? ((pluginData.guild.channels.cache.get(attachmentChannelId) as TextBasedChannel) ?? backupChannel) : backupChannel; if (!channel) { diff --git a/backend/src/plugins/Common/functions/getEmoji.ts b/backend/src/plugins/Common/functions/getEmoji.ts index 336146066..ef91719a5 100644 --- a/backend/src/plugins/Common/functions/getEmoji.ts +++ b/backend/src/plugins/Common/functions/getEmoji.ts @@ -1,6 +1,6 @@ import { GuildPluginData } from "knub"; -import { CommonPluginType } from "../types.js"; import { env } from "../../../env.js"; +import { CommonPluginType } from "../types.js"; export function getSuccessEmoji(pluginData: GuildPluginData) { return pluginData.config.get().success_emoji ?? env.DEFAULT_SUCCESS_EMOJI; diff --git a/backend/src/plugins/Logs/types.ts b/backend/src/plugins/Logs/types.ts index 1efbbc628..552d3cf61 100644 --- a/backend/src/plugins/Logs/types.ts +++ b/backend/src/plugins/Logs/types.ts @@ -6,7 +6,7 @@ import { GuildCases } from "../../data/GuildCases.js"; import { GuildLogs } from "../../data/GuildLogs.js"; import { GuildSavedMessages } from "../../data/GuildSavedMessages.js"; import { LogType } from "../../data/LogType.js"; -import { keys, zBoundedCharacters, zEmbedInput, zMessageContent, zRegex, zSnowflake, zStrictMessageContent } from "../../utils.js"; +import { keys, zBoundedCharacters, zMessageContent, zRegex, zSnowflake } from "../../utils.js"; import { MessageBuffer } from "../../utils/MessageBuffer.js"; import { TemplateSafeCase, @@ -30,10 +30,13 @@ const MAX_BATCH_TIME = 5000; // A bit of a workaround so we can pass LogType keys to z.enum() const zMessageContentWithDefault = zMessageContent.default(""); const logTypes = keys(LogType); -const logTypeProps = logTypes.reduce((map, type) => { - map[type] = zMessageContent.default(DefaultLogMessages[type] || ""); - return map; -}, {} as Record); +const logTypeProps = logTypes.reduce( + (map, type) => { + map[type] = zMessageContent.default(DefaultLogMessages[type] || ""); + return map; + }, + {} as Record, +); const zLogFormats = z.strictObject(logTypeProps); const zLogChannel = z.strictObject({ diff --git a/backend/src/plugins/ModActions/commands/forcemute/ForceMuteMsgCmd.ts b/backend/src/plugins/ModActions/commands/forcemute/ForceMuteMsgCmd.ts index 129eb9e54..f9389ae3f 100644 --- a/backend/src/plugins/ModActions/commands/forcemute/ForceMuteMsgCmd.ts +++ b/backend/src/plugins/ModActions/commands/forcemute/ForceMuteMsgCmd.ts @@ -77,7 +77,7 @@ export const ForceMuteMsgCmd = modActionsMsgCmd({ [...msg.attachments.values()], mod, ppId, - "time" in args ? args.time ?? undefined : undefined, + "time" in args ? (args.time ?? undefined) : undefined, args.reason, contactMethods, ); diff --git a/backend/src/plugins/ModActions/commands/forcemute/ForceMuteSlashCmd.ts b/backend/src/plugins/ModActions/commands/forcemute/ForceMuteSlashCmd.ts index fabdd2ab2..74f320a2a 100644 --- a/backend/src/plugins/ModActions/commands/forcemute/ForceMuteSlashCmd.ts +++ b/backend/src/plugins/ModActions/commands/forcemute/ForceMuteSlashCmd.ts @@ -68,7 +68,7 @@ export const ForceMuteSlashCmd = modActionsSlashCmd({ ppId = interaction.user.id; } - const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined; + const convertedTime = options.time ? (convertDelayStringToMS(options.time) ?? undefined) : undefined; if (options.time && !convertedTime) { pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`); return; diff --git a/backend/src/plugins/ModActions/commands/forceunmute/ForceUnmuteMsgCmd.ts b/backend/src/plugins/ModActions/commands/forceunmute/ForceUnmuteMsgCmd.ts index b5a7f3c0c..66da1ca98 100644 --- a/backend/src/plugins/ModActions/commands/forceunmute/ForceUnmuteMsgCmd.ts +++ b/backend/src/plugins/ModActions/commands/forceunmute/ForceUnmuteMsgCmd.ts @@ -72,7 +72,7 @@ export const ForceUnmuteMsgCmd = modActionsMsgCmd({ [...msg.attachments.values()], mod, ppId, - "time" in args ? args.time ?? undefined : undefined, + "time" in args ? (args.time ?? undefined) : undefined, args.reason, ); }, diff --git a/backend/src/plugins/ModActions/commands/forceunmute/ForceUnmuteSlashCmd.ts b/backend/src/plugins/ModActions/commands/forceunmute/ForceUnmuteSlashCmd.ts index 1fcd135c1..c62f29bae 100644 --- a/backend/src/plugins/ModActions/commands/forceunmute/ForceUnmuteSlashCmd.ts +++ b/backend/src/plugins/ModActions/commands/forceunmute/ForceUnmuteSlashCmd.ts @@ -52,7 +52,7 @@ export const ForceUnmuteSlashCmd = modActionsSlashCmd({ ppId = interaction.user.id; } - const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined; + const convertedTime = options.time ? (convertDelayStringToMS(options.time) ?? undefined) : undefined; if (options.time && !convertedTime) { pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`); return; diff --git a/backend/src/plugins/ModActions/commands/mute/MuteMsgCmd.ts b/backend/src/plugins/ModActions/commands/mute/MuteMsgCmd.ts index 07b23c62a..6c399d5ca 100644 --- a/backend/src/plugins/ModActions/commands/mute/MuteMsgCmd.ts +++ b/backend/src/plugins/ModActions/commands/mute/MuteMsgCmd.ts @@ -103,7 +103,7 @@ export const MuteMsgCmd = modActionsMsgCmd({ [...msg.attachments.values()], mod, ppId, - "time" in args ? args.time ?? undefined : undefined, + "time" in args ? (args.time ?? undefined) : undefined, args.reason, contactMethods, ); diff --git a/backend/src/plugins/ModActions/commands/mute/MuteSlashCmd.ts b/backend/src/plugins/ModActions/commands/mute/MuteSlashCmd.ts index a8378f76c..7ccf55dbb 100644 --- a/backend/src/plugins/ModActions/commands/mute/MuteSlashCmd.ts +++ b/backend/src/plugins/ModActions/commands/mute/MuteSlashCmd.ts @@ -95,7 +95,7 @@ export const MuteSlashCmd = modActionsSlashCmd({ ppId = interaction.user.id; } - const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined; + const convertedTime = options.time ? (convertDelayStringToMS(options.time) ?? undefined) : undefined; if (options.time && !convertedTime) { pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`); return; diff --git a/backend/src/plugins/ModActions/commands/unmute/UnmuteMsgCmd.ts b/backend/src/plugins/ModActions/commands/unmute/UnmuteMsgCmd.ts index 6c2887ddb..7c76bbb05 100644 --- a/backend/src/plugins/ModActions/commands/unmute/UnmuteMsgCmd.ts +++ b/backend/src/plugins/ModActions/commands/unmute/UnmuteMsgCmd.ts @@ -105,7 +105,7 @@ export const UnmuteMsgCmd = modActionsMsgCmd({ [...msg.attachments.values()], mod, ppId, - "time" in args ? args.time ?? undefined : undefined, + "time" in args ? (args.time ?? undefined) : undefined, args.reason, ); }, diff --git a/backend/src/plugins/ModActions/commands/unmute/UnmuteSlashCmd.ts b/backend/src/plugins/ModActions/commands/unmute/UnmuteSlashCmd.ts index 6d3be623b..a370e6fbe 100644 --- a/backend/src/plugins/ModActions/commands/unmute/UnmuteSlashCmd.ts +++ b/backend/src/plugins/ModActions/commands/unmute/UnmuteSlashCmd.ts @@ -99,7 +99,7 @@ export const UnmuteSlashCmd = modActionsSlashCmd({ ppId = interaction.user.id; } - const convertedTime = options.time ? convertDelayStringToMS(options.time) ?? undefined : undefined; + const convertedTime = options.time ? (convertDelayStringToMS(options.time) ?? undefined) : undefined; if (options.time && !convertedTime) { pluginData.state.common.sendErrorMessage(interaction, `Could not convert ${options.time} to a delay`); return; diff --git a/backend/src/plugins/Mutes/functions/muteUser.ts b/backend/src/plugins/Mutes/functions/muteUser.ts index fbb6497b7..d2a248566 100644 --- a/backend/src/plugins/Mutes/functions/muteUser.ts +++ b/backend/src/plugins/Mutes/functions/muteUser.ts @@ -186,8 +186,8 @@ export async function muteUser( const template = existingMute ? config.update_mute_message : muteTime - ? config.timed_mute_message - : config.mute_message; + ? config.timed_mute_message + : config.mute_message; let muteMessage: string | null = null; try { diff --git a/backend/src/plugins/Phisherman/types.ts b/backend/src/plugins/Phisherman/types.ts index b483cc924..6b7cdb765 100644 --- a/backend/src/plugins/Phisherman/types.ts +++ b/backend/src/plugins/Phisherman/types.ts @@ -7,5 +7,6 @@ export const zPhishermanConfig = z.strictObject({ export interface PhishermanPluginType extends BasePluginType { configSchema: typeof zPhishermanConfig; + // eslint-disable-next-line @typescript-eslint/ban-types state: {}; } diff --git a/backend/src/plugins/TimeAndDate/types.ts b/backend/src/plugins/TimeAndDate/types.ts index 24e1eb3de..02b3d0c91 100644 --- a/backend/src/plugins/TimeAndDate/types.ts +++ b/backend/src/plugins/TimeAndDate/types.ts @@ -1,5 +1,4 @@ import { BasePluginType, guildPluginMessageCommand, pluginUtils } from "knub"; -import { U } from "ts-toolbelt"; import z from "zod/v4"; import { GuildMemberTimezones } from "../../data/GuildMemberTimezones.js"; import { keys } from "../../utils.js"; @@ -7,12 +6,13 @@ import { zValidTimezone } from "../../utils/zValidTimezone.js"; import { CommonPlugin } from "../Common/CommonPlugin.js"; import { defaultDateFormats } from "./defaultDateFormats.js"; -const zDateFormatKeys = z.enum(keys(defaultDateFormats) as U.ListOf); - -const dateFormatTypeMap = keys(defaultDateFormats).reduce((map, key) => { - map[key] = z.string().default(defaultDateFormats[key]); - return map; -}, {} as Record>); +const dateFormatTypeMap = keys(defaultDateFormats).reduce( + (map, key) => { + map[key] = z.string().default(defaultDateFormats[key]); + return map; + }, + {} as Record>, +); export const zTimeAndDateConfig = z.strictObject({ timezone: zValidTimezone(z.string()).default("Etc/UTC"), diff --git a/backend/src/plugins/Utility/functions/fetchChannelMessagesToClean.ts b/backend/src/plugins/Utility/functions/fetchChannelMessagesToClean.ts index 6aed5e56e..0140d2420 100644 --- a/backend/src/plugins/Utility/functions/fetchChannelMessagesToClean.ts +++ b/backend/src/plugins/Utility/functions/fetchChannelMessagesToClean.ts @@ -55,7 +55,7 @@ export async function fetchChannelMessagesToClean( pinIds = new Set((await targetChannel.messages.fetchPinned()).keys()); } - let rawMessagesToClean: Array>> = []; + const rawMessagesToClean: Array>> = []; let beforeId = opts.beforeId; let requests = 0; while (rawMessagesToClean.length < opts.count) { diff --git a/backend/src/plugins/Utility/functions/getInviteInfoEmbed.ts b/backend/src/plugins/Utility/functions/getInviteInfoEmbed.ts index 72a14a33f..daf2c78ff 100644 --- a/backend/src/plugins/Utility/functions/getInviteInfoEmbed.ts +++ b/backend/src/plugins/Utility/functions/getInviteInfoEmbed.ts @@ -18,7 +18,7 @@ export async function getInviteInfoEmbed( pluginData: GuildPluginData, inviteCode: string, ): Promise { - let invite = await resolveInvite(pluginData.client, inviteCode, true); + const invite = await resolveInvite(pluginData.client, inviteCode, true); if (!invite) { return null; } diff --git a/backend/src/utils.ts b/backend/src/utils.ts index a6c949edf..d7ecb9584 100644 --- a/backend/src/utils.ts +++ b/backend/src/utils.ts @@ -1,7 +1,6 @@ import { APIEmbed, ChannelType, - ChatInputCommandInteraction, Client, DiscordAPIError, EmbedData, @@ -20,14 +19,11 @@ import { Message, MessageCreateOptions, MessageMentionOptions, - PartialChannelData, PartialGroupDMChannel, PartialMessage, - PartialUser, RoleResolvable, SendableChannels, Sticker, - TextBasedChannel, User, } from "discord.js"; import emojiRegex from "emoji-regex"; @@ -197,94 +193,99 @@ export function zRegex(zStr: T) { }); } -export const zEmbedInput = z.strictObject({ - title: z.string().optional(), - description: z.string().optional(), - url: z.string().optional(), - timestamp: z.string().optional(), - color: z.number().optional(), +export const zEmbedInput = z + .strictObject({ + title: z.string().optional(), + description: z.string().optional(), + url: z.string().optional(), + timestamp: z.string().optional(), + color: z.number().optional(), - footer: z.optional( - z.object({ - text: z.string(), - icon_url: z.string().optional(), - }), - ), - - image: z.optional( - z.object({ - url: z.string().optional(), - width: z.number().optional(), - height: z.number().optional(), - }), - ), - - thumbnail: z.optional( - z.object({ - url: z.string().optional(), - width: z.number().optional(), - height: z.number().optional(), - }), - ), - - video: z.optional( - z.object({ - url: z.string().optional(), - width: z.number().optional(), - height: z.number().optional(), - }), - ), + footer: z.optional( + z.object({ + text: z.string(), + icon_url: z.string().optional(), + }), + ), - provider: z.optional( - z.object({ - name: z.string(), - url: z.string().optional(), - }), - ), + image: z.optional( + z.object({ + url: z.string().optional(), + width: z.number().optional(), + height: z.number().optional(), + }), + ), - fields: z.optional( - z.array( + thumbnail: z.optional( z.object({ - name: z.string().optional(), - value: z.string().optional(), - inline: z.boolean().optional(), + url: z.string().optional(), + width: z.number().optional(), + height: z.number().optional(), }), ), - ), - author: z - .optional( + video: z.optional( z.object({ - name: z.string(), url: z.string().optional(), width: z.number().optional(), height: z.number().optional(), }), - ) - .nullable(), -}).meta({ - id: "embedInput", -}); + ), + + provider: z.optional( + z.object({ + name: z.string(), + url: z.string().optional(), + }), + ), + + fields: z.optional( + z.array( + z.object({ + name: z.string().optional(), + value: z.string().optional(), + inline: z.boolean().optional(), + }), + ), + ), + + author: z + .optional( + z.object({ + name: z.string(), + url: z.string().optional(), + width: z.number().optional(), + height: z.number().optional(), + }), + ) + .nullable(), + }) + .meta({ + id: "embedInput", + }); export type EmbedWith = APIEmbed & Pick, T>; -export const zStrictMessageContent = z.strictObject({ - content: z.string().optional(), - tts: z.boolean().optional(), - embeds: z.union([z.array(zEmbedInput), zEmbedInput]).optional(), - embed: zEmbedInput.optional(), -}).transform((data) => { - if (data.embed) { - data.embeds = [data.embed]; - delete data.embed; - } - if (data.embeds && !Array.isArray(data.embeds)) { - data.embeds = [data.embeds]; - } - return data as StrictMessageContent; -}).meta({ - id: "strictMessageContent", -}); +export const zStrictMessageContent = z + .strictObject({ + content: z.string().optional(), + tts: z.boolean().optional(), + embeds: z.union([z.array(zEmbedInput), zEmbedInput]).optional(), + embed: zEmbedInput.optional(), + }) + .transform((data) => { + if (data.embed) { + data.embeds = [data.embed]; + delete data.embed; + } + if (data.embeds && !Array.isArray(data.embeds)) { + data.embeds = [data.embeds]; + } + return data as StrictMessageContent; + }) + .meta({ + id: "strictMessageContent", + }); export type ZStrictMessageContent = z.infer; @@ -295,10 +296,7 @@ export type StrictMessageContent = { }; export type MessageContent = string | StrictMessageContent; -export const zMessageContent = z.union([ - zBoundedCharacters(0, 4000), - zStrictMessageContent, -]); +export const zMessageContent = z.union([zBoundedCharacters(0, 4000), zStrictMessageContent]); export function validateAndParseMessageContent(input: unknown): StrictMessageContent { if (input == null) { diff --git a/backend/src/utils/getOrFetchGuildMember.ts b/backend/src/utils/getOrFetchGuildMember.ts index f5f480163..d17ff621c 100644 --- a/backend/src/utils/getOrFetchGuildMember.ts +++ b/backend/src/utils/getOrFetchGuildMember.ts @@ -15,7 +15,8 @@ export async function getOrFetchGuildMember(guild: Guild, memberId: string): Pro if (!getOrFetchGuildMemberPromises.has(key)) { getOrFetchGuildMemberPromises.set( key, - guild.members.fetch(memberId) + guild.members + .fetch(memberId) .catch(() => undefined) .finally(() => { getOrFetchGuildMemberPromises.delete(key); diff --git a/backend/src/utils/getOrFetchUser.ts b/backend/src/utils/getOrFetchUser.ts index 49adc71e3..84cf7994b 100644 --- a/backend/src/utils/getOrFetchUser.ts +++ b/backend/src/utils/getOrFetchUser.ts @@ -15,7 +15,8 @@ export async function getOrFetchUser(bot: Client, userId: string): Promise undefined) .finally(() => { getOrFetchUserPromises.delete(userId); diff --git a/dashboard/.eslintrc.js b/dashboard/.eslintrc.js deleted file mode 100644 index 49370f9ac..000000000 --- a/dashboard/.eslintrc.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - extends: ["../.eslintrc.js"], - rules: { - "@typescript-eslint/no-unused-vars": 0, - "no-self-assign": 0, - "no-empty": 0, - "@typescript-eslint/no-var-requires": 0, - }, -}; diff --git a/dashboard/.eslintrc.json b/dashboard/.eslintrc.json new file mode 100644 index 000000000..a269db3ca --- /dev/null +++ b/dashboard/.eslintrc.json @@ -0,0 +1,9 @@ +{ + "extends": ["../.eslintrc.js"], + "rules": { + "@typescript-eslint/no-unused-vars": 0, + "no-self-assign": 0, + "no-empty": 0, + "@typescript-eslint/no-var-requires": 0 + } +} diff --git a/dashboard/index.html b/dashboard/index.html index f7448266a..4ab7bf218 100644 --- a/dashboard/index.html +++ b/dashboard/index.html @@ -1,4 +1,4 @@ - + diff --git a/dashboard/src/style/base.css b/dashboard/src/style/base.css index 62560244e..f3f0a9694 100644 --- a/dashboard/src/style/base.css +++ b/dashboard/src/style/base.css @@ -1,4 +1,13 @@ body { font: normal 18px/1.5 sans-serif; - font-family: system, -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto", "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif; + font-family: + system, + -apple-system, + ".SFNSText-Regular", + "San Francisco", + "Roboto", + "Segoe UI", + "Helvetica Neue", + "Lucida Grande", + sans-serif; } diff --git a/dashboard/src/style/docs.css b/dashboard/src/style/docs.css index e2e11dd36..dc4548be9 100644 --- a/dashboard/src/style/docs.css +++ b/dashboard/src/style/docs.css @@ -6,6 +6,6 @@ @media (width < theme(--breakpoint-lg)) { .docs-sidebar.closed:not(:focus-within) { - @apply sr-only; + @apply sr-only; } } diff --git a/dashboard/src/style/splash.css b/dashboard/src/style/splash.css index 0ef4fb92a..d502512f6 100644 --- a/dashboard/src/style/splash.css +++ b/dashboard/src/style/splash.css @@ -121,7 +121,7 @@ & li:not(:first-child)::before { display: block; - content: ' '; + content: " "; width: 4px; height: 4px; border-radius: 50%; diff --git a/dashboard/src/vite-env.d.ts b/dashboard/src/vite-env.d.ts index ead6f8ec3..c8504cdfa 100644 --- a/dashboard/src/vite-env.d.ts +++ b/dashboard/src/vite-env.d.ts @@ -1,6 +1,6 @@ /// -declare module '*.html' { +declare module "*.html" { const value: string; export default value; } diff --git a/package-lock.json b/package-lock.json index adfb7e702..69dc9b67c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,7 +21,7 @@ "@typescript-eslint/parser": "^5.59.5", "eslint": "^8.40.0", "eslint-config-prettier": "^8.8.0", - "prettier": "^2.8.4", + "prettier": "^3.5.3", "prettier-plugin-organize-imports": "^3.2.2", "ts-toolbelt": "^9.6.0", "tsc-watch": "^6.0.4", @@ -9370,14 +9370,16 @@ } }, "node_modules/prettier": { - "version": "2.8.8", + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", + "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", "dev": true, "license": "MIT", "bin": { - "prettier": "bin-prettier.js" + "prettier": "bin/prettier.cjs" }, "engines": { - "node": ">=10.13.0" + "node": ">=14" }, "funding": { "url": "https://github.com/prettier/prettier?sponsor=1" diff --git a/package.json b/package.json index 21a8f2010..dd04c47e5 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@typescript-eslint/parser": "^5.59.5", "eslint": "^8.40.0", "eslint-config-prettier": "^8.8.0", - "prettier": "^2.8.4", + "prettier": "^3.5.3", "prettier-plugin-organize-imports": "^3.2.2", "ts-toolbelt": "^9.6.0", "tsc-watch": "^6.0.4",