2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-26 11:57:09 +00:00
2017-09-24 14:28:31 +03:30

35 lines
811 B
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
// Utils
const { link } = require('../../utils/tg');
// Bot
const { replyOptions } = require('../../bot/options');
// DB
const Warn = require('../../stores/warn');
const admins = require('../../stores/admin');
const unwarnHandler = async ({ message, reply }) => {
if (!await admins.isAdmin(message.from)) {
return null;
}
if (!message.reply_to_message) {
return reply(' <b>Reply to a message.</b>', replyOptions);
}
const messageToUnwarn = message.reply_to_message;
const userToUnwarn = messageToUnwarn.from;
const allWarns = await Warn.getWarns(userToUnwarn);
const warn = await Warn.unwarn(userToUnwarn);
return reply(
`${link(userToUnwarn)} <b>was pardoned for:</b>\n\n${warn}` +
`(${allWarns.length}/3)`,
replyOptions);
};
module.exports = unwarnHandler;