From 44d966971a42ab3ebfcd246705d9c7641921bd04 Mon Sep 17 00:00:00 2001 From: Ean Milligan Date: Sat, 26 Apr 2025 22:30:44 -0400 Subject: [PATCH] Add BigInt override to allow JSON.stringify to function smoothly --- mod.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/mod.ts b/mod.ts index 3da03b1..1e0337b 100644 --- a/mod.ts +++ b/mod.ts @@ -29,6 +29,15 @@ import intervals from './src/intervals.ts'; import { successColor, warnColor } from './src/commandUtils.ts'; import utils from './src/utils.ts'; +// Extend the BigInt prototype to support JSON.stringify +interface BigIntX extends BigInt { + /** Convert to BigInt to string form in JSON.stringify */ + toJSON: () => string; +} +(BigInt.prototype as BigIntX).toJSON = function () { + return this.toString(); +}; + // Initialize logging client with folder to use for logs, needs --allow-write set on Deno startup initLog('logs', DEBUG); @@ -183,6 +192,7 @@ startBot({ .catch((e) => utils.commonLoggers.dbError('mod.ts:100', 'delete from', e)); }, debug: DEVMODE ? (dmsg) => log(LT.LOG, `Debug Message | ${JSON.stringify(dmsg)}`) : undefined, + raw: DEVMODE ? (dmsg) => log(LT.LOG, `Raw Debug Message | ${JSON.stringify(dmsg)}`) : undefined, messageCreate: (message: DiscordenoMessage) => { // Ignore all other bots if (message.isBot) return; @@ -325,7 +335,7 @@ startBot({ }); // Start up the command prompt for debug usage -if (DEBUG) { +if (DEBUG && DEVMODE) { utils.cmdPrompt(config.logChannel, config.name); }