Downloading files

Downloading files is fairly simple using the downloadMedia method.

First, you'll need to get the media somehow. the easiest way would be to either use getMessages

const result = await client.getMessages("me", {
    ids: 87581 // the id of the message you want to download
});
const media = result[0].media;
if (media) {
    const buffer = await client.downloadMedia(media, {
        workers: 1,
    });
    console.log("result is", buffer);
}

You could also get the from events. See the Updates doc on how to do that.

Last updated