You can then use this function to download the attachment. I liked the idea, so I added it directly in the API 5a5063a
\nFinal code
\n;(async () => {\n api.update_guildId_and_channelId_withCurrentlyVisible()\n let channelId = api.getConfig().channelId\n\n const messages = await api.getMessages(channelId)\n console.log(messages)\n \n console.log('List of attachments in the latest message', messages[0].attachments)\n console.log('URL of the first attachment in the latest message', messages[0].attachments[0].url)\n api.downloadFileByUrl(messages[0].attachments[0].url, messages[0].attachments[0].filename)\n})()
-
See the title... I wan to download the attachment from a message that I received... |
Beta Was this translation helpful? Give feedback.
-
You can read the attachments inside a message at the key See in the Discord documentation, the Example image attachment {
"id": "1198292395519909948",
"filename": "2024-01-07_23-28-19.png",
"size": 10358,
"url": "https://cdn.discordapp.com/attachments/826934811846377545/1198292395519909948/2024-01-07_23-28-19.png?ex=65be5fc2&is=65abeac2&hm=b4a6d3c271e28969e5ae836c776f3597ceda7b326c24949f30b43a29a7791cde&",
"proxy_url": "https://media.discordapp.net/attachments/826934811846377545/1198292395519909948/2024-01-07_23-28-19.png?ex=65be5fc2&is=65abeac2&hm=b4a6d3c271e28969e5ae836c776f3597ceda7b326c24949f30b43a29a7791cde&",
"width": 144,
"height": 127,
"content_type": "image/png",
"placeholder": "x/cBBoAnqGaGeIeAeaNXmEeEqXyPXvU=",
"placeholder_version": 1
} You can then use this function to download the attachment. I liked the idea, so I added it directly in the API 5a5063a Final code ;(async () => {
api.update_guildId_and_channelId_withCurrentlyVisible()
let channelId = api.getConfig().channelId
const messages = await api.getMessages(channelId)
console.log(messages)
console.log('List of attachments in the latest message', messages[0].attachments)
console.log('URL of the first attachment in the latest message', messages[0].attachments[0].url)
api.downloadFileByUrl(messages[0].attachments[0].url, messages[0].attachments[0].filename)
})() |
Beta Was this translation helpful? Give feedback.
You can read the attachments inside a message at the key
attachments
See in the Discord documentation, the
Message
data modelExample image attachment