mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-09-02 23:25:20 +00:00
/unwarn unbans
This commit is contained in:
@@ -7,9 +7,10 @@ const { link } = require('../../utils/tg');
|
|||||||
const { replyOptions } = require('../../bot/options');
|
const { replyOptions } = require('../../bot/options');
|
||||||
|
|
||||||
// DB
|
// DB
|
||||||
|
const { listGroups } = require('../../stores/group');
|
||||||
const { getWarns, unwarn } = require('../../stores/user');
|
const { getWarns, unwarn } = require('../../stores/user');
|
||||||
|
|
||||||
const unwarnHandler = async ({ message, reply, state }) => {
|
const unwarnHandler = async ({ message, reply, state, telegram }) => {
|
||||||
const { isAdmin, user } = state;
|
const { isAdmin, user } = state;
|
||||||
if (!isAdmin) return null;
|
if (!isAdmin) return null;
|
||||||
|
|
||||||
@@ -31,6 +32,11 @@ const unwarnHandler = async ({ message, reply, state }) => {
|
|||||||
replyOptions);
|
replyOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const groups = await listGroups();
|
||||||
|
|
||||||
|
groups.forEach(group =>
|
||||||
|
telegram.unbanChatMember(group.id, userToUnwarn.id));
|
||||||
|
|
||||||
await unwarn(userToUnwarn);
|
await unwarn(userToUnwarn);
|
||||||
|
|
||||||
return reply(
|
return reply(
|
||||||
|
@@ -62,7 +62,7 @@ const warn = ({ id }, reason) =>
|
|||||||
User.update({ id }, { $push: { warns: reason } });
|
User.update({ id }, { $push: { warns: reason } });
|
||||||
|
|
||||||
const unwarn = ({ id }) =>
|
const unwarn = ({ id }) =>
|
||||||
User.update({ id }, { $pop: { warns: 1 } });
|
User.update({ id }, { $pop: { warns: 1 }, $set: { status: 'member' } });
|
||||||
|
|
||||||
const nowarns = ({ id }) =>
|
const nowarns = ({ id }) =>
|
||||||
User.update({ id }, { $set: { warns: [] } });
|
User.update({ id }, { $set: { warns: [] } });
|
||||||
|
Reference in New Issue
Block a user