2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-29 21:27:47 +00:00

fixed channel forwarding warn count bug

This commit is contained in:
Pouria Ezzati 2017-10-11 00:16:34 +03:30
parent 7904e1db6c
commit 89a8b5875f

View File

@ -16,7 +16,7 @@ const bot = require('../../bot');
const { replyOptions } = require('../../bot/options');
// DB
const { ban, warn } = require('../../stores/user');
const { ban, warn, getWarns } = require('../../stores/user');
const { listGroups } = require('../../stores/group');
const removeLinks = async ({ message, chat, reply, state }, next) => {
@ -48,13 +48,14 @@ const removeLinks = async ({ message, chat, reply, state }, next) => {
return next();
}
const reason = 'Channel forward/link';
const warnCount = await warn(user, reason);
await warn(user, reason);
const warnCount = await getWarns(user);
const promises = [
bot.telegram.deleteMessage(chat.id, message.message_id)
];
if (warnCount < numberOfWarnsToBan) {
if (warnCount.length < numberOfWarnsToBan) {
promises.push(reply(
`⚠️ ${link(user)} <b>got warned!</b> (${warnCount}/3)` +
`⚠️ ${link(user)} <b>got warned!</b> (${warnCount.length}/3)` +
`\n\nReason: ${reason}`,
replyOptions));
} else {
@ -62,7 +63,7 @@ const removeLinks = async ({ message, chat, reply, state }, next) => {
promises.push(ban(user,
'Reached max number of warnings'));
promises.push(reply(
`🚫 ${link(user)} <b>got banned</b>! (${warnCount}/3)` +
`🚫 ${link(user)} <b>got banned</b>! (${warnCount.length}/3)` +
'\n\nReason: Reached max number of warnings',
replyOptions));
}