From 862c5ea1358f96aa72da4008477cfbf12a467320 Mon Sep 17 00:00:00 2001 From: zkldi <20380519+zkldi@users.noreply.github.com> Date: Sat, 12 Nov 2022 00:31:13 +0000 Subject: [PATCH] fix: make bot work --- bot/src/config.ts | 14 +++++++------- bot/src/utils/logger.ts | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bot/src/config.ts b/bot/src/config.ts index deab9d7e6..b000f7bdc 100644 --- a/bot/src/config.ts +++ b/bot/src/config.ts @@ -1,5 +1,3 @@ -import { LoggerLayers } from "./data/data"; -import { CreateLayeredLogger } from "./utils/logger"; import { IsRecord } from "./utils/predicates"; import { FormatPrError } from "./utils/prudence"; import { config } from "dotenv"; @@ -19,7 +17,9 @@ config(); // Reads the bots config file from $pwd/conf.json5. // Validates it using prudence. -const logger = CreateLayeredLogger(LoggerLayers.botConfigSetup); +// the real logger tries to bind to discord, and is dependent on the options +// below. +const logger = console; export interface BotConfig { TACHI_SERVER_LOCATION: string; @@ -36,7 +36,7 @@ export interface BotConfig { GAME_CHANNELS: Partial>; ADMIN_USERS: Array; }; - LOGGER: { + LOGGER?: { SEQ_API_KEY?: string; }; } @@ -86,9 +86,9 @@ function ParseBotConfig(fileLoc = "conf.json5"): BotConfig { // A list of users that are allowed to do powerful stuff. ADMIN_USERS: ["string"], }, - LOGGER: { + LOGGER: p.optional({ SEQ_API_KEY: "*string", - }, + }), }); if (err) { @@ -153,7 +153,7 @@ function GetServerConfig() { const res = fetchSync(`${BotConfig.TACHI_SERVER_LOCATION}/api/v1/config`).json(); if (!res.success) { - logger.crit( + logger.error( `Failed to fetch server info from ${BotConfig.TACHI_SERVER_LOCATION}. Can't run.` ); process.exit(1); diff --git a/bot/src/utils/logger.ts b/bot/src/utils/logger.ts index 0876bdf07..a768b3c39 100644 --- a/bot/src/utils/logger.ts +++ b/bot/src/utils/logger.ts @@ -7,7 +7,7 @@ import type { SeqLogLevel } from "seq-logging"; const logger = CreateLogger(`tachi-bot`, undefined, []); -if (BotConfig.LOGGER.SEQ_API_KEY && ProcessEnv.seqUrl) { +if (BotConfig.LOGGER?.SEQ_API_KEY && ProcessEnv.seqUrl) { // Turns winston log levels into seq format. const levelMap: Record = { crit: "Fatal",