File tree Expand file tree Collapse file tree 3 files changed +9
-15
lines changed
Expand file tree Collapse file tree 3 files changed +9
-15
lines changed Original file line number Diff line number Diff line change @@ -27,19 +27,11 @@ const DEFAULT_BATCH_TIME = 1000;
2727const MIN_BATCH_TIME = 250 ;
2828const MAX_BATCH_TIME = 5000 ;
2929
30- const zStrictLogMessageContent = zStrictMessageContent . extend ( {
31- embed : zEmbedInput . optional ( ) ,
32- } ) ;
33- const zLogMessageContent = z . union ( [
34- zBoundedCharacters ( 0 , 2000 ) ,
35- zStrictLogMessageContent ,
36- ] ) ;
37-
3830// A bit of a workaround so we can pass LogType keys to z.enum()
39- const zMessageContentWithDefault = zLogMessageContent . default ( "" ) ;
31+ const zMessageContentWithDefault = zMessageContent . default ( "" ) ;
4032const logTypes = keys ( LogType ) ;
4133const logTypeProps = logTypes . reduce ( ( map , type ) => {
42- map [ type ] = zLogMessageContent . default ( DefaultLogMessages [ type ] || "" ) ;
34+ map [ type ] = zMessageContent . default ( DefaultLogMessages [ type ] || "" ) ;
4335 return map ;
4436} , { } as Record < keyof typeof LogType , typeof zMessageContentWithDefault > ) ;
4537const zLogFormats = z . strictObject ( logTypeProps ) ;
Original file line number Diff line number Diff line change @@ -37,11 +37,6 @@ export async function getLogMessage<TLogType extends keyof ILogTypeData>(
3737 const format = opts ?. format ?. [ LogType [ type ] ] || config . format [ LogType [ type ] ] || "" ;
3838 if ( format === "" || format == null ) return null ;
3939
40- if ( typeof format === "object" && format . embed ) {
41- format . embeds = [ format . embed ] ;
42- delete format . embed ;
43- }
44-
4540 // See comment on FORMAT_NO_TIMESTAMP in types.ts
4641 const timestampFormat = opts ?. timestamp_format ?? config . timestamp_format ;
4742
Original file line number Diff line number Diff line change @@ -270,6 +270,13 @@ export const zStrictMessageContent = z.strictObject({
270270 content : z . string ( ) . optional ( ) ,
271271 tts : z . boolean ( ) . optional ( ) ,
272272 embeds : z . array ( zEmbedInput ) . optional ( ) ,
273+ embed : zEmbedInput . optional ( ) ,
274+ } ) . transform ( ( data ) => {
275+ if ( data . embed ) {
276+ data . embeds = [ data . embed ] ;
277+ delete data . embed ;
278+ }
279+ return data as StrictMessageContent ;
273280} ) ;
274281
275282export type ZStrictMessageContent = z . infer < typeof zStrictMessageContent > ;
You can’t perform that action at this time.
0 commit comments