From 6c05593d82be3df97f5937ce4057ec9e50c98d0e Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Tue, 16 Jan 2024 13:24:01 +0000 Subject: [PATCH] fix: asinine JS spec issue --- bot/src/main.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bot/src/main.ts b/bot/src/main.ts index c9f1432d1..d25af97c8 100644 --- a/bot/src/main.ts +++ b/bot/src/main.ts @@ -10,6 +10,17 @@ import { Client, Intents } from "discord.js"; import { GetLimboChannel } from "utils/misc"; import type { CommandInteraction, SelectMenuInteraction } from "discord.js"; +// hack: DiscordJS's endpoints sometimes return bigints that end up in our logger. +// when our logger tries to format that content, JSON.stringify fails. +// +// I personally cannot believe that the spec now made JSON.stringify fallible in such +// a common case. It's kind of absurdly ridiculous. But hey ho; monkey patch our way +// out of it. +// @ts-expect-error hack +BigInt.prototype.toJSON = function toJSON() { + return this.toString(); +}; + const logger = CreateLayeredLogger(LoggerLayers.client); export const client = new Client({