2
0
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:
GingerPlusPlus
2017-09-23 14:35:45 +02:00
parent e99d857df6
commit 43cd7ab285

View File

@@ -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);