Answer the question
In order to leave comments, you need to log in
How to avoid errors with the /ban command?
I wrote the code to remove users from the chat:
@dp.message_handler(commands=['ban'])
async def ban(message: types.Message):
if not message.reply_to_message:
pass
else:
await message.bot.ban_chat_member(message.chat.id, message.reply_to_message.from_user.id)
Answer the question
In order to leave comments, you need to log in
As an option to wrap in try except
@dp.message_handler(commands=['ban'])
async def ban(message: types.Message):
try:
await message.bot.ban_chat_member(message.chat.id, message.reply_to_message.from_user.id)
except:
pass
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question