mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-30 05:37:59 +00:00
/unadmin attempts to revoke admin permissions in all groups
This commit is contained in:
parent
feba5c1f43
commit
eb83119492
@ -6,9 +6,26 @@ const { logError } = require('../../utils/log');
|
||||
|
||||
// Bot
|
||||
const { replyOptions } = require('../../bot/options');
|
||||
const { telegram } = require('../../bot');
|
||||
|
||||
// DB
|
||||
const { isAdmin, unadmin } = require('../../stores/user');
|
||||
const { listGroups } = require('../../stores/group');
|
||||
|
||||
const noop = Function.prototype;
|
||||
|
||||
const tgUnadmin = async (userToUnadmin) => {
|
||||
for (const group of await listGroups()) {
|
||||
telegram.promoteChatMember(group.id, userToUnadmin.id, {
|
||||
can_change_info: false,
|
||||
can_delete_messages: false,
|
||||
can_invite_users: false,
|
||||
can_pin_messages: false,
|
||||
can_promote_members: false,
|
||||
can_restrict_members: false,
|
||||
}).catch(noop);
|
||||
}
|
||||
};
|
||||
|
||||
const unAdminHandler = async ({ message, reply, state }) => {
|
||||
const { isMaster } = state;
|
||||
@ -34,6 +51,8 @@ const unAdminHandler = async ({ message, reply, state }) => {
|
||||
);
|
||||
}
|
||||
|
||||
tgUnadmin(userToUnadmin);
|
||||
|
||||
try {
|
||||
await unadmin(userToUnadmin);
|
||||
} catch (err) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user