Improve error message when trying to delete inline messages

Closes #4129.
This commit is contained in:
Lonami Exo 2023-06-09 17:47:59 +02:00
parent 1e63de9b68
commit 9267917031

View File

@ -338,6 +338,8 @@ class CallbackQuery(EventBuilder):
This method will likely fail if `via_inline` is `True`.
"""
self._client.loop.create_task(self.answer())
if isinstance(self.query.msg_id, (types.InputBotInlineMessageID, types.InputBotInlineMessageID64)):
raise TypeError('Inline messages cannot be deleted as there is no API request available to do so')
return await self._client.delete_messages(
await self.get_input_chat(), [self.query.msg_id],
*args, **kwargs