Merge pull request #63

* Add ephemeral attachment field

* I did not miss a comma
This commit is contained in:
Gnome! 2021-09-21 19:51:23 +01:00 committed by GitHub
parent e65415d3c8
commit fba7ca420c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -169,9 +169,14 @@ class Attachment(Hashable):
The attachment's `media type <https://en.wikipedia.org/wiki/Media_type>`_
.. versionadded:: 1.7
ephemeral: Optional[:class:`bool`]
If the attachment is ephemeral. Ephemeral attachments are temporary and
will automatically be removed after a set period of time.
.. versionadded:: 2.0
"""
__slots__ = ("id", "size", "height", "width", "filename", "url", "proxy_url", "_http", "content_type")
__slots__ = ("id", "size", "height", "width", "filename", "url", "proxy_url", "ephemeral", "_http", "content_type")
def __init__(self, *, data: AttachmentPayload, state: ConnectionState):
self.id: int = int(data["id"])
@ -183,6 +188,7 @@ class Attachment(Hashable):
self.proxy_url: str = data.get("proxy_url")
self._http = state.http
self.content_type: Optional[str] = data.get("content_type")
self.ephemeral: Optional[bool] = data.get("ephemeral")
def is_spoiler(self) -> bool:
""":class:`bool`: Whether this attachment contains a spoiler."""

View File

@ -53,6 +53,7 @@ class _AttachmentOptional(TypedDict, total=False):
height: Optional[int]
width: Optional[int]
content_type: str
ephemeral: bool
spoiler: bool