2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-09-05 16:45:18 +00:00
Files
the-guard-bot/handlers/commands/getwarns.js

29 lines
669 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
2017-09-21 23:47:26 +04:30
const getWarnsHandler = async ({ message, reply }) => {
2017-09-21 13:57:49 +04:30
if (!await admins.isAdmin(message.from)) {
return null;
}
if (!message.reply_to_message) {
return reply('Reply to a message');
}
let i = 0;
const theUser = message.reply_to_message.from;
2017-09-21 23:47:26 +04:30
return reply('Warns for ' + link(theUser) + ':\n\n' +
2017-09-21 13:57:49 +04:30
(await Warn.getWarns(theUser))
.map(x => ++i + '. ' + x)
2017-09-21 23:47:26 +04:30
.join('\n\n'), replyOptions);
2017-09-21 13:57:49 +04:30
};
2017-09-21 23:47:26 +04:30
module.exports = getWarnsHandler;