aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--discord/message.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/discord/message.py b/discord/message.py
index e1b88f12..abad3bb1 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):
+ async def to_file(self, use_cached=False):
"""|coro|
Converts the attachment into a :class:`File` suitable for sending via
@@ -174,6 +174,16 @@ class Attachment:
.. versionadded:: 1.3
+ Parameters
+ -----------
+ use_cached: :class:`bool`
+ Whether to use :attr:`proxy_url` rather than :attr:`url` when downloading
+ the attachment. This will allow attachments to be saved after deletion
+ more often, compared to the regular URL which is generally deleted right
+ after the message is deleted. Note that this can still fail to download
+ deleted attachments if too much time has passed and it does not work
+ on some types of attachments.
+
Raises
------
HTTPException
@@ -189,7 +199,7 @@ class Attachment:
The attachment as a file suitable for sending.
"""
- data = await self.read()
+ data = await self.read(use_cached=use_cached)
return File(io.BytesIO(data), filename=self.filename)
def flatten_handlers(cls):