2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-09-01 14:45:27 +00:00

Always send warn message on /warn

even when the last warning gets the target banned.
Closes #38

Also, use numberOfWarnsToBan instead of 3.
This commit is contained in:
GingerPlusPlus
2017-10-31 19:08:17 +01:00
parent 61d5cd9950
commit 84e178f363

View File

@@ -55,18 +55,25 @@ const warnHandler = async ({ message, chat, reply, me, state }) => {
message.reply_to_message.message_id)); message.reply_to_message.message_id));
} }
if (warnCount.length < numberOfWarnsToBan) { try {
promises.push(reply( await reply(
`⚠️ ${link(user)} <b>warned</b> ${link(userToWarn)} ` + `⚠️ ${link(user)} <b>warned</b> ${link(userToWarn)} <b>for:</b>` +
`<b>for:</b>\n\n ${reason} (${warnCount.length}/3)`, `\n\n${reason} (${warnCount.length}/${numberOfWarnsToBan})`,
replyOptions)); replyOptions);
} else { } catch (e) {
// we don't expect an error
// but we do wish to continue if one happens
// to ban people who reach max number of warnings
logError(e);
}
if (warnCount.length >= numberOfWarnsToBan) {
promises.push(bot.telegram.kickChatMember(chat.id, userToWarn.id)); promises.push(bot.telegram.kickChatMember(chat.id, userToWarn.id));
promises.push(ban(userToWarn, 'Reached max number of warnings')); promises.push(ban(userToWarn, 'Reached max number of warnings'));
promises.push(reply( promises.push(reply(
`🚫 ${link(user)} <b>banned</b> ${link(userToWarn)} ` + `🚫 ${link(user)} <b>banned</b> ${link(userToWarn)} ` +
'<b>for:</b>\n\nReached max number of warnings ' + '<b>for:</b>\n\nReached max number of warnings ' +
`(${warnCount.length}/3)\n\n`, `(${warnCount.length}/${numberOfWarnsToBan})`,
replyOptions)); replyOptions));
} }