3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-06-16 02:55:03 +00:00

fix: more auto-transforms for zStrictMessageContent

This commit is contained in:
Dragory 2025-06-01 00:08:02 +00:00
parent a59707e2a5
commit 84c1d7f82d
No known key found for this signature in database

View file

@ -269,14 +269,17 @@ export type EmbedWith<T extends keyof APIEmbed> = APIEmbed & Pick<Required<APIEm
export const zStrictMessageContent = z.strictObject({
content: z.string().optional(),
tts: z.boolean().optional(),
embeds: z.array(zEmbedInput).optional(),
embeds: z.union([z.array(zEmbedInput), zEmbedInput]).optional(),
embed: zEmbedInput.optional(),
}).transform((data) => {
}).refine((data) => {
if (data.embed) {
data.embeds = [data.embed];
delete data.embed;
}
return data as StrictMessageContent;
if (data.embeds && !Array.isArray(data.embeds)) {
data.embeds = [data.embeds];
}
return true;
});
export type ZStrictMessageContent = z.infer<typeof zStrictMessageContent>;