From ddc1a587a0f9cabecb322bebb00f1b2177e436a2 Mon Sep 17 00:00:00 2001 From: Nefrace Date: Tue, 9 Mar 2021 22:27:32 +0300 Subject: [PATCH] Changed order of checks for karma processing --- index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 6bbe0f4..55ed727 100644 --- a/index.js +++ b/index.js @@ -449,6 +449,12 @@ async function processKarma(msg, match, settings={}) { bot.sendMessage(chat_id, message, {reply_to_message_id: msg.message_id}) return } + if (timeDiff < chat.options.karmaCooldown){ + const messages = await Trigger.find({trigger:'tooFast', show: true}) + const message = messages[getRandomInt(0, messages.length)].text + bot.sendMessage(chat_id, message, {reply_to_message_id: msg.message_id}) + return + } if(to.id === me.id) { let messages let change = true @@ -464,12 +470,6 @@ async function processKarma(msg, match, settings={}) { return } } - if (timeDiff < chat.options.karmaCooldown){ - const messages = await Trigger.find({trigger:'tooFast', show: true}) - const message = messages[getRandomInt(0, messages.length)].text - bot.sendMessage(chat_id, message, {reply_to_message_id: msg.message_id}) - return - } if (to.is_bot && to.id != me.id) { return }