mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-06-16 19:15:03 +00:00
fix: more auto-transforms for zStrictMessageContent
This commit is contained in:
parent
a59707e2a5
commit
84c1d7f82d
1 changed files with 6 additions and 3 deletions
|
@ -269,14 +269,17 @@ export type EmbedWith<T extends keyof APIEmbed> = APIEmbed & Pick<Required<APIEm
|
||||||
export const zStrictMessageContent = z.strictObject({
|
export const zStrictMessageContent = z.strictObject({
|
||||||
content: z.string().optional(),
|
content: z.string().optional(),
|
||||||
tts: z.boolean().optional(),
|
tts: z.boolean().optional(),
|
||||||
embeds: z.array(zEmbedInput).optional(),
|
embeds: z.union([z.array(zEmbedInput), zEmbedInput]).optional(),
|
||||||
embed: zEmbedInput.optional(),
|
embed: zEmbedInput.optional(),
|
||||||
}).transform((data) => {
|
}).refine((data) => {
|
||||||
if (data.embed) {
|
if (data.embed) {
|
||||||
data.embeds = [data.embed];
|
data.embeds = [data.embed];
|
||||||
delete 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>;
|
export type ZStrictMessageContent = z.infer<typeof zStrictMessageContent>;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue