Skip to content

Commit 23ac796

Browse files
committed
Don't ban / warn in PM, don't ban / warn itself
1 parent 42fef1d commit 23ac796

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

handlers/commands/ban.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const { replyOptions } = require('../../bot/options');
1212
const { listGroups } = require('../../stores/group');
1313
const { isAdmin, isBanned, ban } = require('../../stores/user');
1414

15-
const banHandler = async ({ chat, message, reply, telegram }) => {
15+
const banHandler = async ({ chat, message, reply, telegram, me }) => {
1616
if (!await isAdmin(message.from)) {
1717
return null;
1818
}
@@ -29,6 +29,10 @@ const banHandler = async ({ chat, message, reply, telegram }) => {
2929
replyOptions);
3030
}
3131

32+
if (message.chat.type === 'private' || userToBan.username === me) {
33+
return null;
34+
}
35+
3236
if (reason.length === 0) {
3337
return reply('ℹ️ <b>Need a reason to ban.</b>', replyOptions);
3438
}

handlers/commands/warn.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const { replyOptions } = require('../../bot/options');
1515
// DB
1616
const { isAdmin, ban, getWarns, warn } = require('../../stores/user');
1717

18-
const warnHandler = async ({ message, chat, reply }) => {
18+
const warnHandler = async ({ message, chat, reply, me }) => {
1919
if (!await isAdmin(message.from)) {
2020
return null;
2121
}
@@ -31,6 +31,10 @@ const warnHandler = async ({ message, chat, reply }) => {
3131
replyOptions);
3232
}
3333

34+
if (message.chat.type === 'private' || userToWarn.username === me) {
35+
return null;
36+
}
37+
3438
const reason = message.text.split(' ').slice(1).join(' ').trim();
3539

3640
if (reason.length === 0) {

0 commit comments

Comments
 (0)