3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-06-07 16:05:01 +00:00

fix: log channel config requiring full format array

This commit is contained in:
Dragory 2025-05-31 18:14:39 +00:00
parent 35f5deb19a
commit 21374fa804
No known key found for this signature in database

View file

@ -6,7 +6,7 @@ import { GuildCases } from "../../data/GuildCases.js";
import { GuildLogs } from "../../data/GuildLogs.js"; import { GuildLogs } from "../../data/GuildLogs.js";
import { GuildSavedMessages } from "../../data/GuildSavedMessages.js"; import { GuildSavedMessages } from "../../data/GuildSavedMessages.js";
import { LogType } from "../../data/LogType.js"; import { LogType } from "../../data/LogType.js";
import { zBoundedCharacters, zMessageContent, zRegex, zSnowflake } from "../../utils.js"; import { keys, zBoundedCharacters, zMessageContent, zRegex, zSnowflake } from "../../utils.js";
import { MessageBuffer } from "../../utils/MessageBuffer.js"; import { MessageBuffer } from "../../utils/MessageBuffer.js";
import { import {
TemplateSafeCase, TemplateSafeCase,
@ -28,9 +28,12 @@ const MIN_BATCH_TIME = 250;
const MAX_BATCH_TIME = 5000; const MAX_BATCH_TIME = 5000;
// A bit of a workaround so we can pass LogType keys to z.enum() // A bit of a workaround so we can pass LogType keys to z.enum()
const logTypes = Object.keys(LogType) as [keyof typeof LogType, ...Array<keyof typeof LogType>]; const logTypes = keys(LogType);
const zLogFormats = z.record(z.enum(logTypes), zMessageContent); const logTypeProps = logTypes.reduce((map, type) => {
type TLogFormats = z.infer<typeof zLogFormats>; map[type] = zMessageContent;
return map;
}, {} as Record<keyof typeof LogType, typeof zMessageContent>);
const zLogFormats = z.strictObject(logTypeProps);
const zLogChannel = z.strictObject({ const zLogChannel = z.strictObject({
include: z.array(zBoundedCharacters(1, 255)).default([]), include: z.array(zBoundedCharacters(1, 255)).default([]),
@ -44,7 +47,7 @@ const zLogChannel = z.strictObject({
excluded_threads: z.array(zSnowflake).nullable().default(null), excluded_threads: z.array(zSnowflake).nullable().default(null),
exclude_bots: z.boolean().default(false), exclude_bots: z.boolean().default(false),
excluded_roles: z.array(zSnowflake).nullable().default(null), excluded_roles: z.array(zSnowflake).nullable().default(null),
format: zLogFormats.default({} as TLogFormats), format: zLogFormats.partial().default({}),
timestamp_format: z.string().nullable().default(null), timestamp_format: z.string().nullable().default(null),
include_embed_timestamp: z.boolean().nullable().default(null), include_embed_timestamp: z.boolean().nullable().default(null),
}); });