Browse Source

Add spoiler keyword argument to Attachment.to_file

pull/4126/head
Zomatree 5 years ago
committed by Rapptz
parent
commit
a22d38d004
  1. 8
      discord/message.py

8
discord/message.py

@ -166,7 +166,7 @@ class Attachment:
data = await self._http.get_from_cdn(url)
return data
async def to_file(self, *, use_cached=False):
async def to_file(self, *, use_cached=False, spoiler=False):
"""|coro|
Converts the attachment into a :class:`File` suitable for sending via
@ -184,6 +184,10 @@ class Attachment:
deleted attachments if too much time has passed and it does not work
on some types of attachments.
.. versionadded:: 1.4
spoiler: :class:`bool`
Whether the file is a spoiler.
.. versionadded:: 1.4
Raises
@ -202,7 +206,7 @@ class Attachment:
"""
data = await self.read(use_cached=use_cached)
return File(io.BytesIO(data), filename=self.filename)
return File(io.BytesIO(data), filename=self.filename, spoiler=spoiler)
def flatten_handlers(cls):
prefix = len('_handle_')

Loading…
Cancel
Save