2017-09-21 13:57:49 +04:30
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
// Utils
|
2017-09-23 21:40:58 +03:30
|
|
|
|
const { link } = require('../../utils/tg');
|
2017-09-21 13:57:49 +04:30
|
|
|
|
|
|
|
|
|
// Bot
|
2017-09-23 21:40:58 +03:30
|
|
|
|
const { replyOptions } = require('../../bot/options');
|
2017-09-21 13:57:49 +04:30
|
|
|
|
|
|
|
|
|
// DB
|
2017-09-23 21:40:58 +03:30
|
|
|
|
const Warn = require('../../stores/warn');
|
2017-09-27 00:11:20 +03:30
|
|
|
|
const { isAdmin } = require('../../stores/user');
|
2017-09-21 13:57:49 +04:30
|
|
|
|
|
|
|
|
|
const unwarnHandler = async ({ message, reply }) => {
|
2017-09-27 00:11:20 +03:30
|
|
|
|
if (!await isAdmin(message.from)) {
|
2017-09-21 13:57:49 +04:30
|
|
|
|
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
|
|
|
|
|
2017-09-21 18:20:50 +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;
|