mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-22 08:44:10 +00:00
Add use_cached to Attachment.to_file
This commit is contained in:
parent
6a30f2749f
commit
c2d5c2e118
@ -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):
|
||||
|
Loading…
x
Reference in New Issue
Block a user