stop on mysql error

This commit is contained in:
2020-05-12 00:34:56 +02:00
parent 04e32e7ba7
commit bd71f90f6b

View File

@@ -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`)
});