mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-31 14:15:25 +00:00
/unban calls unbanChatMember in each group
This commit is contained in:
@@ -7,10 +7,11 @@ const { link } = require('../utils/tg');
|
||||
const { replyOptions } = require('../bot/options');
|
||||
|
||||
// DB
|
||||
const { listGroups } = require('../stores/groups');
|
||||
const { isBanned, unban } = require('../stores/ban');
|
||||
const admins = require('../stores/admin');
|
||||
|
||||
const unbanHandler = async ({ message, reply }) => {
|
||||
const unbanHandler = async ({ message, reply, telegram }) => {
|
||||
if (!await admins.isAdmin(message.from)) {
|
||||
return null;
|
||||
}
|
||||
@@ -25,6 +26,13 @@ const unbanHandler = async ({ message, reply }) => {
|
||||
return reply('User is not banned.');
|
||||
}
|
||||
|
||||
const groups = await listGroups();
|
||||
|
||||
const unbans = groups.map(group =>
|
||||
telegram.unbanChatMember(group.id, userToUnban.id));
|
||||
|
||||
await Promise.all(unbans);
|
||||
|
||||
await unban(userToUnban);
|
||||
|
||||
return reply(`${link(userToUnban)} has been unbanned.`, replyOptions);
|
||||
|
Reference in New Issue
Block a user