mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-10-16 11:58:10 +00:00
Add MessageType.is_deletable to fix Messageable.purge failing
Fix #10319
This commit is contained in:
@@ -195,6 +195,9 @@ async def _purge_helper(
|
||||
count = 0
|
||||
await asyncio.sleep(1)
|
||||
|
||||
if not message.type.is_deletable():
|
||||
continue
|
||||
|
||||
if not check(message):
|
||||
continue
|
||||
|
||||
|
@@ -279,6 +279,16 @@ class MessageType(Enum):
|
||||
poll_result = 46
|
||||
emoji_added = 63
|
||||
|
||||
def is_deletable(self) -> bool:
|
||||
return self not in {
|
||||
MessageType.recipient_add,
|
||||
MessageType.recipient_remove,
|
||||
MessageType.call,
|
||||
MessageType.channel_name_change,
|
||||
MessageType.channel_icon_change,
|
||||
MessageType.thread_starter_message,
|
||||
}
|
||||
|
||||
|
||||
class SpeakingState(Enum):
|
||||
none = 0
|
||||
|
@@ -1732,6 +1732,15 @@ of :class:`enum.Enum`.
|
||||
|
||||
Checks if two messages are not equal.
|
||||
|
||||
.. method:: is_deletable()
|
||||
|
||||
Checks if the message type is deletable, as some system messages cannot be deleted.
|
||||
|
||||
.. versionadded:: 2.7
|
||||
|
||||
:return: A boolean denoting if the message type is deletable.
|
||||
:rtype: :class:`bool`
|
||||
|
||||
.. attribute:: default
|
||||
|
||||
The default message type. This is the same as regular messages.
|
||||
|
Reference in New Issue
Block a user