From 354074089d4f5b8489dbd0e5246a4c93219d2ff9 Mon Sep 17 00:00:00 2001 From: liushuyu Date: Sun, 24 May 2020 00:21:40 -0600 Subject: [PATCH] data: do not crash if the response file is bad --- src/data.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/data.ts b/src/data.ts index 8eb4399..780ef99 100644 --- a/src/data.ts +++ b/src/data.ts @@ -32,8 +32,12 @@ export function readBans () { export function readCustomResponses () { // Load the responses file into the responses variable. - state.responses = require(`./responses/${process.env.TENANT}.json`); - logger.debug(`Loaded responses file for ${process.env.TENANT} from external source.`); + try { + state.responses = require(`./responses/${process.env.TENANT}.json`); + logger.debug(`Loaded responses file for ${process.env.TENANT} from external source.`); + } catch (e) { + logger.error(`Failed to load ${process.env.TENANT}.json! Custom responses are disabled.`); + } } export function flushWarnings () {