2
0
mirror of https://github.com/thedevs-network/the-guard-bot synced 2025-08-30 21:55:17 +00:00

/unwarn unbans

This commit is contained in:
GingerPlusPlus
2017-10-28 20:24:13 +02:00
parent f3666f25f8
commit 9e728e33c7
2 changed files with 8 additions and 2 deletions

View File

@@ -7,9 +7,10 @@ const { link } = require('../../utils/tg');
const { replyOptions } = require('../../bot/options');
// DB
const { listGroups } = require('../../stores/group');
const { getWarns, unwarn } = require('../../stores/user');
const unwarnHandler = async ({ message, reply, state }) => {
const unwarnHandler = async ({ message, reply, state, telegram }) => {
const { isAdmin, user } = state;
if (!isAdmin) return null;
@@ -31,6 +32,11 @@ const unwarnHandler = async ({ message, reply, state }) => {
replyOptions);
}
const groups = await listGroups();
groups.forEach(group =>
telegram.unbanChatMember(group.id, userToUnwarn.id));
await unwarn(userToUnwarn);
return reply(

View File

@@ -62,7 +62,7 @@ const warn = ({ id }, reason) =>
User.update({ id }, { $push: { warns: reason } });
const unwarn = ({ id }) =>
User.update({ id }, { $pop: { warns: 1 } });
User.update({ id }, { $pop: { warns: 1 }, $set: { status: 'member' } });
const nowarns = ({ id }) =>
User.update({ id }, { $set: { warns: [] } });