Skip to content

Commit

Permalink
/ban works with both username or telegramID (#417)
Browse files Browse the repository at this point in the history
  • Loading branch information
UsmanAR authored Aug 9, 2023
1 parent 40498c5 commit cac6724
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions bot/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,13 +502,13 @@ const initialize = (botToken, options) => {

bot.command('ban', adminMiddleware, async ctx => {
try {
let [username] = await validateParams(ctx, 2, '\\<_username_\\>');
let [username] = await validateParams(ctx, 2, '\\<_username or telegramID_\\>');

if (!username) return;

username = username[0] == '@' ? username.slice(1) : username;

const user = await User.findOne({ username });
let userTelegramId = username;
const user = await User.findOne({ $or: [{username : username},{tg_id:userTelegramId}] });
if (!user) {
await messages.notFoundUserMessage(ctx);
return;
Expand Down

0 comments on commit cac6724

Please sign in to comment.