-
See the title... I wan to download the attachment from a message that I received... |
Beta Was this translation helpful? Give feedback.
Answered by
rigwild
Jan 20, 2024
Replies: 1 comment
-
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.
0 replies
Answer selected by
rigwild
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can read the attachments inside a message at the key
attachments
See in the Discord documentation, the
Message
data modelExample image attachment