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-09-24 22:17:27 +03:30
|
|
|
|
const { getWarns } = require('../../stores/warn');
|
2017-09-23 21:40:58 +03:30
|
|
|
|
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;
|
2017-09-24 22:17:27 +03:30
|
|
|
|
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` +
|
2017-09-24 22:17:27 +03:30
|
|
|
|
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;
|