This release introduces a feature to get a message's attachments.
Messages now have a downloadMedia()
function, which is a promise that will return an object in the following format:
{
mimetype: 'image/jpeg',
filename: '' // if it's a document, this will have the original filename of the file
data: 'data:image/jpeg;base64,/9j/4AAQS...'
}
You can check if a message has media attached by using the hasMedia
property. This works for images, videos, audio, voice notes, documents and stickers!