Download message attachments (images, documents, etc)

This commit is contained in:
Pedro Lopez
2019-11-24 04:23:08 -04:00
parent dfcf76c139
commit 64912dccfd
4 changed files with 74 additions and 6 deletions

View File

@@ -81,6 +81,14 @@ client.on('message', async msg => {
} else if(msg.body == '!chats') {
const chats = await client.getChats();
client.sendMessage(msg.from, `The bot has ${chats.length} chats open.`);
} else if(msg.body == '!mediainfo' && msg.hasMedia) {
const attachmentData = await msg.downloadMedia();
msg.reply(`
*Media info*
MimeType: ${attachmentData.mimetype}
Filename: ${attachmentData.filename}
Data (length): ${attachmentData.data.length}
`);
}
});