Сам код:
#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