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

40 lines
899 B
JavaScript
Raw Normal View History

2017-09-21 13:57:49 +04:30
'use strict';
// Utils
const { link } = require('../../utils/tg');
2017-09-21 13:57:49 +04:30
// Bot
const { replyOptions } = require('../../bot/options');
2017-09-21 13:57:49 +04:30
// DB
const Warn = require('../../stores/warn');
const admins = require('../../stores/admin');
2017-09-21 13:57:49 +04:30
const unwarnHandler = async ({ message, reply }) => {
if (!await admins.isAdmin(message.from)) {
return null;
}
2017-09-25 12:40:04 +03:30
const userToUnwarn = message.reply_to_message
? message.reply_to_message.from
: message.commandMention
? message.commandMention
: null;
if (!userToUnwarn) {
return reply(' <b>Reply to a message or mention a user.</b>',
replyOptions);
}
2017-09-21 13:57:49 +04:30
const allWarns = await Warn.getWarns(userToUnwarn);
2017-09-21 13:57:49 +04:30
const warn = await Warn.unwarn(userToUnwarn);
return reply(
2017-09-24 23:24:34 +03:30
`${link(message.from)} <b>pardoned</b> ${link(userToUnwarn)} ` +
`<b>for:</b>\n\n${warn} (${allWarns.length}/3)`,
2017-09-21 13:57:49 +04:30
replyOptions);
};
module.exports = unwarnHandler;