summary refs log tree commit diff
path: root/src/util/util/JSON.ts
blob: b092eb8800b34736f7aed4fcf5db7826aada5afb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
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 };