2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-30 05:37:59 +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'); const { replyOptions } = require('../../bot/options');
// DB // DB
const { ban, warn } = require('../../stores/user'); const { ban, warn, getWarns } = require('../../stores/user');
const { listGroups } = require('../../stores/group'); const { listGroups } = require('../../stores/group');
const removeLinks = async ({ message, chat, reply, state }, next) => { const removeLinks = async ({ message, chat, reply, state }, next) => {
@ -48,13 +48,14 @@ const removeLinks = async ({ message, chat, reply, state }, next) => {
return next(); return next();
} }
const reason = 'Channel forward/link'; const reason = 'Channel forward/link';
const warnCount = await warn(user, reason); await warn(user, reason);
const warnCount = await getWarns(user);
const promises = [ const promises = [
bot.telegram.deleteMessage(chat.id, message.message_id) bot.telegram.deleteMessage(chat.id, message.message_id)
]; ];
if (warnCount < numberOfWarnsToBan) { if (warnCount.length < numberOfWarnsToBan) {
promises.push(reply( promises.push(reply(
`⚠️ ${link(user)} <b>got warned!</b> (${warnCount}/3)` + `⚠️ ${link(user)} <b>got warned!</b> (${warnCount.length}/3)` +
`\n\nReason: ${reason}`, `\n\nReason: ${reason}`,
replyOptions)); replyOptions));
} else { } else {
@ -62,7 +63,7 @@ const removeLinks = async ({ message, chat, reply, state }, next) => {
promises.push(ban(user, promises.push(ban(user,
'Reached max number of warnings')); 'Reached max number of warnings'));
promises.push(reply( 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', '\n\nReason: Reached max number of warnings',
replyOptions)); replyOptions));
} }