Fix gateway encoding Date objects as {} when using erlpack. Fixes NaN/NaN/NaN timestamps in desktop client
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
// Discord.com sends ISO strings with +00:00 extension, not Z
|
||||
// This causes issues with Python bot libs
|
||||
const JSONReplacer = function (
|
||||
this: { [key: string]: unknown },
|
||||
key: string,
|
||||
value: unknown,
|
||||
) {
|
||||
if (this[key] instanceof Date) {
|
||||
return (this[key] as Date).toISOString().replace("Z", "+00:00");
|
||||
}
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
export { JSONReplacer };
|
||||
@@ -40,3 +40,4 @@ export * from "./TraverseDirectory";
|
||||
export * from "./InvisibleCharacters";
|
||||
export * from "./Sentry";
|
||||
export * from "./WebAuthn";
|
||||
export * from "./JSON";
|
||||
|
||||
Reference in New Issue
Block a user