2017-09-21 13:57:49 +04:30
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
// Utils
|
2017-09-23 21:40:58 +03:30
|
|
|
|
const { link } = require('../../utils/tg');
|
2017-09-21 13:57:49 +04:30
|
|
|
|
|
|
|
|
|
// Bot
|
2017-09-23 21:40:58 +03:30
|
|
|
|
const { replyOptions } = require('../../bot/options');
|
2017-09-21 13:57:49 +04:30
|
|
|
|
|
|
|
|
|
// DB
|
2017-10-06 16:34:23 +03:30
|
|
|
|
const { getWarns } = require('../../stores/user');
|
2017-09-21 13:57:49 +04:30
|
|
|
|
|
2017-10-06 16:34:23 +03:30
|
|
|
|
const getWarnsHandler = async ({ message, reply, state }) => {
|
|
|
|
|
const { isAdmin } = state;
|
2017-10-06 16:40:49 +03:30
|
|
|
|
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;
|
2017-09-24 22:17:27 +03:30
|
|
|
|
const warns = await getWarns(theUser);
|
2017-09-27 12:34:26 +03:30
|
|
|
|
if (!warns) {
|
2017-09-24 22:17:27 +03:30
|
|
|
|
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` +
|
2017-09-24 22:17:27 +03:30
|
|
|
|
warns
|
2017-09-24 14:28:18 +03:30
|
|
|
|
.map(warn => ++i + '. ' + warn)
|
2017-09-27 12:34:26 +03:30
|
|
|
|
.join('\n'), replyOptions);
|
2017-09-21 13:57:49 +04:30
|
|
|
|
};
|
|
|
|
|
|
2017-09-21 23:47:26 +04:30
|
|
|
|
module.exports = getWarnsHandler;
|