Ошибка при попытке забанить человека в беседе Telegram бота — Python (aiogram)?

Сам код:

#bot init
bot = Bot(token=config.TOKEN)
dp = Dispatcher(bot)

#filters
dp.filters_factory.bind(IsAdminFilter)

#ban 
@dp.message_handler(is_admin=True, commands=["ban"], commands_prefix="!/")
async def cmd_ban(message: types.Message):
	if not message.reply_to_message:
		await message.reply("Эта команда должна быть ответом на сообщение, йоу нига!")
		return

	await message.bot.delete_message(chat_id=config.GROUP_ID, message_id=message.message_id)
	await message.bot.kick_chat_member(chat_id=config.GROUP_ID, user_id=message.reply_to_message.from_user.id)

	await message.reply_to_message.reply("Этот нига забанен!!!")


#мат
@dp.message_handler()
async def filter_messages(message: types.Message):
	if "бл=ть" in message.text:
		await message.reply("Не ругайся матом!")
		await message.delete()

# run long-polling 
if __name__ == "__main__":
	executor.start_polling(dp, skip_updates=True)


Сама ошибка
ERROR:asyncio:Task exception was never retrieved
future: <Task finished name='Task-12' coro=<Dispatcher._process_polling_updates() done, defined at C:\Users\KatyaTheBest\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiogram\dispatcher\dispatcher.py:331> exception=MessageToDeleteNotFound('Message to delete not found')>
Traceback (most recent call last):
  File "C:\Users\KatyaTheBest\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 339, in _process_polling_updates
    for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
  File "C:\Users\KatyaTheBest\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 194, in process_updates
    return await asyncio.gather(*tasks)
  File "C:\Users\KatyaTheBest\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiogram\dispatcher\handler.py", line 117, in notify
    response = await handler_obj.handler(*args, **partial_data)
  File "C:\Users\KatyaTheBest\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 214, in process_update
    return await self.message_handlers.notify(update.message)
  File "C:\Users\KatyaTheBest\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiogram\dispatcher\handler.py", line 117, in notify
    response = await handler_obj.handler(*args, **partial_data)
  File "bot.py", line 25, in cmd_ban
    await message.bot.delete_message(chat_id=config.GROUP_ID, message_id=message.message_id)
  File "C:\Users\KatyaTheBest\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiogram\bot\bot.py", line 1780, in delete_message
    result = await self.request(api.Methods.DELETE_MESSAGE, payload)
  File "C:\Users\KatyaTheBest\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiogram\bot\base.py", line 201, in request
    return await api.make_request(self.session, self.__token, method, data, files,
  File "C:\Users\KatyaTheBest\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiogram\bot\api.py", line 104, in make_request
    return check_result(method, response.content_type, response.status, await response.text())
  File "C:\Users\KatyaTheBest\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiogram\bot\api.py", line 78, in check_result
    exceptions.BadRequest.detect(description)
  File "C:\Users\KatyaTheBest\AppData\Local\Programs\Python\Python38-32\lib\site-packages\aiogram\utils\exceptions.py", line 136, in detect
    raise err(cls.text or description)
aiogram.utils.exceptions.MessageToDeleteNotFound: Message to delete not found
  • Вопрос задан
  • 663 просмотра
Пригласить эксперта
Ответы на вопрос 1
Дарова. Смог решить проблему? У меня с баном тоже траблы. код без ошибок, но команда не работает.

Пишу бота на aiogram, никакие ошибки не выходят. Команда бан не работает, хотя все правильно. Ват ту ду?
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы