-
Used to be I could just do something along the lines of this to upload a copy of attachments to a separate channel after the message was deleted for logging purposes (IE: Images, Videos, etc) attachments = []
attachment_links = []
if len(message.attachments) > 0:
for attachment in message.attachments:
attachments.append(await attachment.to_file())
attachment_links.append(attachment.url)
attachment_urls = '\n'.join(attachment_links)
embed.add_field(name='Attachments', value=attachment_urls, inline=False)
await channel.send(embed=embed)
await channel.send(files=attachments) Which used to work without fail 100% of the time- (I assume because attachment links had a time lag before they expired after message deletion) This thought is further reinforced by looking at the error raised in question 2024-06-06 14:59:06 ERROR discord.client Ignoring exception in on_message_delete
Traceback (most recent call last):
File "/home/peppermint/vpy/lib/python3.12/site-packages/discord/client.py", line 441, in _run_event
await coro(*args, **kwargs)
File "/home/pep/Desktop/Development/DiscordBots/Hybrid/Spoopy/test.py", line XX, in on_message_delete
attachments.append(await attachment.to_file())
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pep/vpy/lib/python3.12/site-packages/discord/message.py", line 325, in read
data = await self._http.get_from_cdn(url)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/pep/vpy/lib/python3.12/site-packages/discord/http.py", line 769, in get_from_cdn
raise NotFound(resp, 'asset not found')
discord.errors.NotFound: 404 Not Found (error code: 0): asset not found Just looking for confirmation on whether or not the API changed, or I need to update my code- or I'm simply going insane. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
This has never worked. At best, proxy_urls would be cached for a bit longer than the parent attachment URL. This has been mentioned in the documentation for years as far as I know. |
Beta Was this translation helpful? Give feedback.
This has never worked. At best, proxy_urls would be cached for a bit longer than the parent attachment URL. This has been mentioned in the documentation for years as far as I know.