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

33 lines
839 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 { getWarns } = 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) {
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
}
let i = 0;
const theUser = message.reply_to_message.from;
const warns = await getWarns(theUser);
if (warns.length < 1) {
return reply(`✅ <b>no warns for:</b> ${link(theUser)}`, replyOptions);
}
2017-09-24 14:28:18 +03:30
return reply(`⚠️ <b>Warns for</b> ${link(theUser)}:\n\n` +
warns
2017-09-24 14:28:18 +03:30
.map(warn => ++i + '. ' + warn)
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;