mirror of
https://github.com/thedevs-network/the-guard-bot
synced 2025-09-01 14:45:27 +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 { isAdmin, isBanned, ban } = require('../../stores/user');
|
||||||
|
|
||||||
const banHandler = async ({ chat, message, reply, telegram, me, state }) => {
|
const banHandler = async ({ chat, message, reply, telegram, me, state }) => {
|
||||||
if (!state.isAdmin) return null;
|
|
||||||
|
|
||||||
const userToBan = message.reply_to_message
|
const userToBan = message.reply_to_message
|
||||||
? message.reply_to_message.from
|
? message.reply_to_message.from
|
||||||
: message.commandMention
|
: message.commandMention
|
||||||
@@ -22,6 +20,15 @@ const banHandler = async ({ chat, message, reply, telegram, me, state }) => {
|
|||||||
: null;
|
: null;
|
||||||
const reason = message.text.split(' ').slice(1).join(' ').trim();
|
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) {
|
if (!userToBan) {
|
||||||
return reply(
|
return reply(
|
||||||
'ℹ️ <b>Reply to a message or mention a user.</b>',
|
'ℹ️ <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);
|
).then(scheduleDeletion);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.chat.type === 'private' || userToBan.username === me) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (await isAdmin(userToBan)) {
|
if (await isAdmin(userToBan)) {
|
||||||
return reply('ℹ️ <b>Can\'t ban other admins.</b>', replyOptions);
|
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 warnHandler = async ({ message, chat, reply, me, state }) => {
|
||||||
const { user } = state;
|
const { user } = state;
|
||||||
if (!state.isAdmin) return null;
|
|
||||||
|
|
||||||
const userToWarn = message.reply_to_message
|
const userToWarn = message.reply_to_message
|
||||||
? message.reply_to_message.from
|
? message.reply_to_message.from
|
||||||
: message.commandMention
|
: message.commandMention
|
||||||
? message.commandMention
|
? message.commandMention
|
||||||
: null;
|
: 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) {
|
if (!userToWarn) {
|
||||||
return reply(
|
return reply(
|
||||||
'ℹ️ <b>Reply to a message or mentoin a user.</b>',
|
'ℹ️ <b>Reply to a message or mentoin a user.</b>',
|
||||||
@@ -35,10 +43,6 @@ const warnHandler = async ({ message, chat, reply, me, state }) => {
|
|||||||
).then(scheduleDeletion);
|
).then(scheduleDeletion);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.chat.type === 'private' || userToWarn.username === me) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
const reason = message.text.split(' ').slice(1).join(' ').trim();
|
const reason = message.text.split(' ').slice(1).join(' ').trim();
|
||||||
|
|
||||||
if (await isAdmin(userToWarn)) {
|
if (await isAdmin(userToWarn)) {
|
||||||
|
Reference in New Issue
Block a user