Browse Source

Fix attachment is_spoiler() and is_voice_message()

pull/10124/head
dolfies 1 month ago
committed by GitHub
parent
commit
de5720e659
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 5
      discord/message.py

5
discord/message.py

@ -254,11 +254,12 @@ class Attachment(Hashable):
def is_spoiler(self) -> bool:
""":class:`bool`: Whether this attachment contains a spoiler."""
return self.filename.startswith('SPOILER_')
# The flag is technically always present but no harm to check both
return self.filename.startswith('SPOILER_') or self.flags.spoiler
def is_voice_message(self) -> bool:
""":class:`bool`: Whether this attachment is a voice message."""
return self.duration is not None and 'voice-message' in self.url
return self.duration is not None and self.waveform is not None
def __repr__(self) -> str:
return f'<Attachment id={self.id} filename={self.filename!r} url={self.url!r}>'

Loading…
Cancel
Save