@@ -6,7 +6,7 @@ import { GuildCases } from "../../data/GuildCases.js";
66import { GuildLogs } from "../../data/GuildLogs.js" ;
77import { GuildSavedMessages } from "../../data/GuildSavedMessages.js" ;
88import { LogType } from "../../data/LogType.js" ;
9- import { zBoundedCharacters , zMessageContent , zRegex , zSnowflake } from "../../utils.js" ;
9+ import { keys , zBoundedCharacters , zMessageContent , zRegex , zSnowflake } from "../../utils.js" ;
1010import { MessageBuffer } from "../../utils/MessageBuffer.js" ;
1111import {
1212 TemplateSafeCase ,
@@ -28,9 +28,12 @@ const MIN_BATCH_TIME = 250;
2828const MAX_BATCH_TIME = 5000 ;
2929
3030// A bit of a workaround so we can pass LogType keys to z.enum()
31- const logTypes = Object . keys ( LogType ) as [ keyof typeof LogType , ...Array < keyof typeof LogType > ] ;
32- const zLogFormats = z . record ( z . enum ( logTypes ) , zMessageContent ) ;
33- type TLogFormats = z . infer < typeof zLogFormats > ;
31+ const logTypes = keys ( LogType ) ;
32+ const logTypeProps = logTypes . reduce ( ( map , type ) => {
33+ map [ type ] = zMessageContent ;
34+ return map ;
35+ } , { } as Record < keyof typeof LogType , typeof zMessageContent > ) ;
36+ const zLogFormats = z . strictObject ( logTypeProps ) ;
3437
3538const zLogChannel = z . strictObject ( {
3639 include : z . array ( zBoundedCharacters ( 1 , 255 ) ) . default ( [ ] ) ,
@@ -44,7 +47,7 @@ const zLogChannel = z.strictObject({
4447 excluded_threads : z . array ( zSnowflake ) . nullable ( ) . default ( null ) ,
4548 exclude_bots : z . boolean ( ) . default ( false ) ,
4649 excluded_roles : z . array ( zSnowflake ) . nullable ( ) . default ( null ) ,
47- format : zLogFormats . default ( { } as TLogFormats ) ,
50+ format : zLogFormats . partial ( ) . default ( { } ) ,
4851 timestamp_format : z . string ( ) . nullable ( ) . default ( null ) ,
4952 include_embed_timestamp : z . boolean ( ) . nullable ( ) . default ( null ) ,
5053} ) ;
0 commit comments