Skip to content

Commit

Permalink
Add support for getting the attachment's title
Browse files Browse the repository at this point in the history
  • Loading branch information
Soheab authored Aug 28, 2024
1 parent 38bbfed commit a6d1dc0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions discord/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ class Attachment(Hashable):
The waveform (amplitudes) of the audio in bytes. Returns ``None`` if it's not a voice message.
.. versionadded:: 2.3
title: Optional[:class:`str`]
The normalised version of the attachment's filename.
.. versionadded:: 2.5
"""

__slots__ = (
Expand All @@ -211,6 +215,7 @@ class Attachment(Hashable):
'duration',
'waveform',
'_flags',
'title',
)

def __init__(self, *, data: AttachmentPayload, state: ConnectionState):
Expand All @@ -226,6 +231,7 @@ def __init__(self, *, data: AttachmentPayload, state: ConnectionState):
self.description: Optional[str] = data.get('description')
self.ephemeral: bool = data.get('ephemeral', False)
self.duration: Optional[float] = data.get('duration_secs')
self.title: Optional[str] = data.get('title')

waveform = data.get('waveform')
self.waveform: Optional[bytes] = utils._base64_to_bytes(waveform) if waveform is not None else None
Expand Down

0 comments on commit a6d1dc0

Please sign in to comment.