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:
@@ -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(
|
||||
|
@@ -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: [] } });
|
||||
|
Reference in New Issue
Block a user