From 18d96af731afbe085d1b6a7a2d9a11830ddf8bc4 Mon Sep 17 00:00:00 2001 From: Sharon Kennedy Date: Thu, 23 Apr 2020 10:24:03 -0400 Subject: [PATCH] check for presence of transcript file before attempting to write to it --- dist/bot.js | 5 +++++ src/bot.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/dist/bot.js b/dist/bot.js index ff50669..a17c942 100644 --- a/dist/bot.js +++ b/dist/bot.js @@ -184,6 +184,11 @@ class OcrccBot { timeZone: "America/New_York" }); const filepath = this.localStorage.getItem(`${roomId}-transcript`); + + if (!filepath) { + return _logger.default.log("error", `NO TRANSCRIPT FILE FOR ROOM: ${roomId}`); + } + const message = `${sender} [${time}]: ${content.body}\n`; fs.appendFileSync(filepath, message, "utf8"); } catch (err) { diff --git a/src/bot.js b/src/bot.js index 96401ff..9581973 100644 --- a/src/bot.js +++ b/src/bot.js @@ -173,6 +173,11 @@ class OcrccBot { timeZone: "America/New_York" }); const filepath = this.localStorage.getItem(`${roomId}-transcript`) + + if (!filepath) { + return logger.log("error", `NO TRANSCRIPT FILE FOR ROOM: ${roomId}`); + } + const message = `${sender} [${time}]: ${content.body}\n`; fs.appendFileSync(filepath, message, "utf8");