2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-26 11:57:09 +00:00

35 lines
837 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;
}
if (!message.reply_to_message) {
2017-09-24 14:28:18 +03:30
return reply(' <b>Reply to a message.</b>', replyOptions);
2017-09-21 13:57:49 +04:30
}
const messageToUnwarn = message.reply_to_message;
const userToUnwarn = messageToUnwarn.from;
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;