diff --git a/handlers/commands/unadmin.js b/handlers/commands/unadmin.js index 26e3c93..397d657 100644 --- a/handlers/commands/unadmin.js +++ b/handlers/commands/unadmin.js @@ -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) {