mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-08-30 21:55:17 +00:00
send a message when /ban and /warn is used in private chat
This commit is contained in:
@@ -13,8 +13,6 @@ const { listGroups } = require('../../stores/group');
|
||||
const { isAdmin, isBanned, ban } = require('../../stores/user');
|
||||
|
||||
const banHandler = async ({ chat, message, reply, telegram, me, state }) => {
|
||||
if (!state.isAdmin) return null;
|
||||
|
||||
const userToBan = message.reply_to_message
|
||||
? message.reply_to_message.from
|
||||
: message.commandMention
|
||||
@@ -22,6 +20,15 @@ const banHandler = async ({ chat, message, reply, telegram, me, state }) => {
|
||||
: null;
|
||||
const reason = message.text.split(' ').slice(1).join(' ').trim();
|
||||
|
||||
if (!state.isAdmin || userToBan.username === me) return null;
|
||||
|
||||
if (message.chat.type === 'private') {
|
||||
return reply(
|
||||
'ℹ️ <b>This command is only available in groups.</b>',
|
||||
replyOptions
|
||||
);
|
||||
}
|
||||
|
||||
if (!userToBan) {
|
||||
return reply(
|
||||
'ℹ️ <b>Reply to a message or mention a user.</b>',
|
||||
@@ -29,10 +36,6 @@ const banHandler = async ({ chat, message, reply, telegram, me, state }) => {
|
||||
).then(scheduleDeletion);
|
||||
}
|
||||
|
||||
if (message.chat.type === 'private' || userToBan.username === me) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (await isAdmin(userToBan)) {
|
||||
return reply('ℹ️ <b>Can\'t ban other admins.</b>', replyOptions);
|
||||
}
|
||||
|
@@ -20,14 +20,22 @@ const { isAdmin, ban, getWarns, warn } = require('../../stores/user');
|
||||
|
||||
const warnHandler = async ({ message, chat, reply, me, state }) => {
|
||||
const { user } = state;
|
||||
if (!state.isAdmin) return null;
|
||||
|
||||
const userToWarn = message.reply_to_message
|
||||
? message.reply_to_message.from
|
||||
: message.commandMention
|
||||
? message.commandMention
|
||||
: null;
|
||||
|
||||
if (!state.isAdmin || userToWarn.username === me) return null;
|
||||
|
||||
if (message.chat.type === 'private') {
|
||||
return reply(
|
||||
'ℹ️ <b>This command is only available in groups.</b>',
|
||||
replyOptions
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
if (!userToWarn) {
|
||||
return reply(
|
||||
'ℹ️ <b>Reply to a message or mentoin a user.</b>',
|
||||
@@ -35,10 +43,6 @@ const warnHandler = async ({ message, chat, reply, me, state }) => {
|
||||
).then(scheduleDeletion);
|
||||
}
|
||||
|
||||
if (message.chat.type === 'private' || userToWarn.username === me) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const reason = message.text.split(' ').slice(1).join(' ').trim();
|
||||
|
||||
if (await isAdmin(userToWarn)) {
|
||||
|
Reference in New Issue
Block a user