fix: make bot work

This commit is contained in:
zkldi
2022-11-12 00:31:20 +00:00
parent 6d869e7e0f
commit 862c5ea135
2 changed files with 8 additions and 8 deletions
+7 -7
View File
@@ -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<Record<Game, string>>;
ADMIN_USERS: Array<string>;
};
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);
+1 -1
View File
@@ -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<string, SeqLogLevel> = {
crit: "Fatal",