From a22d38d00453320a2271ca79bf99bea31c520d0e Mon Sep 17 00:00:00 2001 From: Zomatree <39768508+zomatree@users.noreply.github.com> Date: Thu, 14 May 2020 00:35:48 +0100 Subject: [PATCH] Add spoiler keyword argument to Attachment.to_file --- discord/message.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/discord/message.py b/discord/message.py index 87d0c9730..884fce6f0 100644 --- a/discord/message.py +++ b/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_')