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

37 lines
881 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/user');
2017-09-21 13:57:49 +04:30
const getWarnsHandler = async ({ message, reply, state }) => {
const { isAdmin } = state;
if (!isAdmin) return null;
2017-09-25 12:40:04 +03:30
const theUser = message.reply_to_message
? message.reply_to_message.from
: message.commandMention
? message.commandMention
: null;
if (!theUser) {
return reply(' <b>Reply to a message or mention a user.</b>',
replyOptions);
2017-09-21 13:57:49 +04:30
}
let i = 0;
const warns = await getWarns(theUser);
if (!warns) {
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)
.join('\n'), replyOptions);
2017-09-21 13:57:49 +04:30
};
2017-09-21 23:47:26 +04:30
module.exports = getWarnsHandler;