2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-24 19:07:17 +00:00

34 lines
720 B
JavaScript
Raw Normal View History

2017-09-21 13:57:49 +04:30
'use strict';
// Utils
const { loadJSON } = require('../../utils/json');
const { link } = require('../../utils/tg');
2017-09-21 13:57:49 +04:30
// Config
const { masterID } = loadJSON('config.json');
2017-09-21 13:57:49 +04:30
// Bot
const { replyOptions } = require('../../bot/options');
2017-09-21 13:57:49 +04:30
// DB
const { isAdmin, admin } = require('../../stores/admin');
2017-09-21 13:57:49 +04:30
const adminHandler = async ({ message, reply }) => {
if (message.from.id !== masterID) {
2017-09-21 13:57:49 +04:30
return null;
}
const userToAdmin = message.reply_to_message
? message.reply_to_message.from
: message.from;
if (await isAdmin(userToAdmin)) {
2017-09-21 13:57:49 +04:30
return reply('Already admin');
}
await admin(userToAdmin);
return reply(`${link(userToAdmin)} is now <b>admin</b>.`, replyOptions);
2017-09-21 13:57:49 +04:30
};
module.exports = adminHandler;