Add content_type to Attachment

This commit is contained in:
Zomatree 2021-04-04 04:26:28 +01:00 committed by GitHub
parent 5b244a7002
commit f8d7be5b78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -111,9 +111,13 @@ class Attachment(Hashable):
The proxy URL. This is a cached version of the :attr:`~Attachment.url` in the
case of images. When the message is deleted, this URL might be valid for a few
minutes or not valid at all.
content_type: Optional[:class:`str`]
The attachment's `media type <https://en.wikipedia.org/wiki/Media_type>`_
.. versionadded: 1.7
"""
__slots__ = ('id', 'size', 'height', 'width', 'filename', 'url', 'proxy_url', '_http')
__slots__ = ('id', 'size', 'height', 'width', 'filename', 'url', 'proxy_url', '_http', 'content_type')
def __init__(self, *, data, state):
self.id = int(data['id'])
@ -124,6 +128,7 @@ class Attachment(Hashable):
self.url = data.get('url')
self.proxy_url = data.get('proxy_url')
self._http = state.http
self.content_type = data.get('content_type')
def is_spoiler(self):
""":class:`bool`: Whether this attachment contains a spoiler."""