mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-23 18:38:05 +00:00
37 lines
792 B
JavaScript
37 lines
792 B
JavaScript
|
'use strict';
|
||
|
|
||
|
// Utils
|
||
|
const { loadJSON } = require('../utils/json');
|
||
|
const { link } = require('../utils/tg');
|
||
|
|
||
|
// 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) {
|
||
|
return reply('Reply to a message');
|
||
|
}
|
||
|
|
||
|
const userToUnadmin = message.reply_to_message.from;
|
||
|
|
||
|
if (!await isAdmin(userToUnadmin)) {
|
||
|
return reply(`${link(userToUnadmin)} is not admin.`, replyOptions);
|
||
|
}
|
||
|
|
||
|
await unadmin(userToUnadmin);
|
||
|
|
||
|
return reply(`${link(userToUnadmin)} is no longer admin.`, replyOptions);
|
||
|
};
|
||
|
|
||
|
module.exports = unAdminHandler;
|