From bd71f90f6b938e513d40314b0e37318e90b7c9e9 Mon Sep 17 00:00:00 2001 From: Oliver Boehlk Date: Tue, 12 May 2020 00:34:56 +0200 Subject: [PATCH] stop on mysql error --- tgBot.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tgBot.js b/tgBot.js index 3d85c9e..0044be4 100644 --- a/tgBot.js +++ b/tgBot.js @@ -92,10 +92,10 @@ const init = async () => { connection.query(querystring, function (error, results, fields) { if (error) { console.error(error); - tgBot.sendMessage(data.message.chat.id, "ERR: sorry, I had trouble querying the database.") + return tgBot.sendMessage(data.message.chat.id, "ERR: sorry, I had trouble querying the database.") } - if (!results) { - tgBot.sendMessage(data.message.chat.id, "WRN: sorry, I didn't find any data matching your request.") + if (!results[0]) { + return tgBot.sendMessage(data.message.chat.id, "WRN: sorry, I didn't find any data matching your request.") } tgBot.sendMessage(data.message.chat.id, `DASH - Simcompany bot made by OTB\nInformation displayed for ${msgData[2]} q${msgData[1]}\nHighest price (24h): ${results[0]["max"]}\nAverage price (24h): ${results[0]["avg"]}\nLowest price (24h): ${results[0]["min"]}\n`) });