@@ -6,11 +6,11 @@ import { MessageFlags } from "oceanic.js";
66import { TomlDate } from "smol-toml" ;
77import { z } from "zod/v4" ;
88
9- export const MessageLiteral = message ( z . string ( ) ) ;
9+ export const MessageLiteral = message ( ( ) => z . string ( ) ) ;
1010export type MessageLiteral = z . infer < typeof MessageLiteral > ;
1111
1212export function messageTemplate < S extends TemplateSchema > ( schema : S ) {
13- const result = message ( template ( schema ) )
13+ const result = message ( markdown => template ( schema , markdown ) )
1414 . transform ( ( { content, embeds, ...message } ) => ( params : ParameterRecord < S > ) => ( {
1515 content : content ?.( params ) ,
1616 embeds : embeds ?. map (
@@ -50,9 +50,9 @@ export function messageTemplate<S extends TemplateSchema>(schema: S) {
5050 return result ;
5151}
5252
53- function message < Z extends z . ZodTypeAny > ( stringType : Z ) {
53+ function message < Z extends z . ZodTypeAny > ( stringType : ( markdown : boolean ) => Z ) {
5454 return z . strictObject ( {
55- content : stringType ,
55+ content : stringType ( true ) ,
5656 allowed_mentions : z . strictObject ( {
5757 everyone : z . boolean ( ) ,
5858 replied_user : z . boolean ( ) ,
@@ -70,24 +70,24 @@ function message<Z extends z.ZodTypeAny>(stringType: Z) {
7070 } ) ) ;
7171}
7272
73- function embed < Z extends z . ZodType > ( stringType : Z ) {
73+ function embed < Z extends z . ZodType > ( stringType : ( markdown : boolean ) => Z ) {
7474 return z . strictObject ( {
75- title : stringType ,
76- description : stringType ,
77- url : stringType ,
75+ title : stringType ( true ) ,
76+ description : stringType ( true ) ,
77+ url : stringType ( false ) ,
7878 timestamp : z . instanceof ( TomlDate ) . transform ( date => date . toISOString ( ) ) , // TODO is this filter consistent with Discord's
7979 color : Color ,
80- footer : z . strictObject ( { text : stringType , icon : stringType } ) ,
81- image : stringType . transform ( url => ( { url } ) ) ,
82- thumbnail : stringType . transform ( url => ( { url } ) ) ,
80+ footer : z . strictObject ( { text : stringType ( false ) , icon : stringType ( false ) } ) ,
81+ image : stringType ( false ) . transform ( url => ( { url } ) ) ,
82+ thumbnail : stringType ( false ) . transform ( url => ( { url } ) ) ,
8383 author : z . strictObject ( {
84- name : stringType ,
85- url : stringType . optional ( ) ,
86- icon_url : stringType . optional ( ) ,
84+ name : stringType ( false ) ,
85+ url : stringType ( false ) . optional ( ) ,
86+ icon_url : stringType ( false ) . optional ( ) ,
8787 } ) . transform ( ( { icon_url, ...input } ) => ( { iconURL : icon_url , ...input } ) ) ,
8888 fields : z . strictObject ( {
89- name : stringType ,
90- value : stringType ,
89+ name : stringType ( true ) ,
90+ value : stringType ( true ) ,
9191 inline : z . boolean ( ) . optional ( ) ,
9292 } ) . array ( ) ,
9393 } ) . partial ( ) ;
0 commit comments