messages.downloadAttachment()

Save file to local computer. Initiates a browser download.

Definition

client.messages.downloadAttachment(
messageId: string|Message,
attachmentId: string|number,
options: ?Object,
):Promise<void,Error>

Parameters

ParameterTypeDescription
messageIdstring|MessageMessage ID
attachmentIdstring|numberAttachment ID
options?ObjectOptions (described below)

Options

ParameterTypeDescription
options.fileNamestringOptional file name used to initiate file save prompt

Response

This function does not return anything, it prompts the browser to save the attachment.

Example

await client.messages.downloadAttachment(message.id, message.attachments[0].id);