3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-03-14 21:31:50 +00:00

Hotfix 20

This commit is contained in:
Dragory 2021-08-19 19:59:25 +03:00
parent 2e49319e9c
commit 5852adadad
No known key found for this signature in database
GPG key ID: 5F387BA66DF8AAC1

View file

@ -430,9 +430,36 @@ export function validateAndParseMessageContent(input: unknown): StrictMessageCon
delete (input as any).embed;
}
dropNullValuesRecursively(input);
return (zStrictMessageContent.parse(input) as unknown) as StrictMessageContent;
}
function dropNullValuesRecursively(obj: any) {
if (obj == null) {
return;
}
if (Array.isArray(obj)) {
for (const item of obj) {
dropNullValuesRecursively(item);
}
}
if (typeof obj !== "object") {
return;
}
for (const [key, value] of Object.entries(obj)) {
if (value == null) {
delete obj[key];
continue;
}
dropNullValuesRecursively(value);
}
}
/**
* Mirrors AllowedMentions from Eris
*/