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

35 lines
770 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) {
return reply('Reply to a message');
}
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(
`${link(userToUnwarn)} was pardoned for: ${warn}\n` +
`(${allWarns.length}/3)`,
2017-09-21 13:57:49 +04:30
replyOptions);
};
module.exports = unwarnHandler;