Changed order of checks for karma processing

This commit is contained in:
Nefrace 2021-03-09 22:27:32 +03:00
parent 5d6ec31186
commit ddc1a587a0
1 changed files with 6 additions and 6 deletions

View File

@ -449,6 +449,12 @@ async function processKarma(msg, match, settings={}) {
bot.sendMessage(chat_id, message, {reply_to_message_id: msg.message_id}) bot.sendMessage(chat_id, message, {reply_to_message_id: msg.message_id})
return 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) { if(to.id === me.id) {
let messages let messages
let change = true let change = true
@ -464,12 +470,6 @@ async function processKarma(msg, match, settings={}) {
return 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) { if (to.is_bot && to.id != me.id) {
return return
} }