2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-24 02:47:48 +00:00

44 lines
979 B
JavaScript
Raw Normal View History

'use strict';
// Utils
const { loadJSON } = require('../../utils/json');
const { link } = require('../../utils/tg');
2017-09-23 21:49:23 +03:30
const { logError } = require('../../utils/log');
// Config
const { masterID } = loadJSON('config.json');
// Bot
const { replyOptions } = require('../../bot/options');
// DB
const { isAdmin, unadmin } = require('../../stores/admin');
const unAdminHandler = async ({ message, reply }) => {
if (message.from.id !== masterID) {
return null;
}
if (!message.reply_to_message) {
2017-09-24 14:28:18 +03:30
return reply(' <b>Reply to a message.</b>', replyOptions);
}
const userToUnadmin = message.reply_to_message.from;
if (!await isAdmin(userToUnadmin)) {
2017-09-24 14:28:18 +03:30
return reply(` ${link(userToUnadmin)} <b>is not admin.</b>`,
replyOptions);
}
2017-09-23 21:49:23 +03:30
try {
await unadmin(userToUnadmin);
} catch (err) {
logError(process.env.DEBUG)(err);
}
2017-09-24 14:28:18 +03:30
return reply(`❗️ ${link(userToUnadmin)} <b>is no longer admin.</b>`,
replyOptions);
};
module.exports = unAdminHandler;