Skip to main content
FileAttachment is a representation of a file attached to a message. Passed into channel.send_files, message.send_files, and message.reply_with_files.

FileAttachment

Fields

FieldTypeDescription
nameStringFile name. Must not be empty.
dataVec<u8>File contents in bytes. Must not be empty.
content_typeOption<String>MIME type. If not set - application/octet-stream is used.
descriptionOption<String>File description. Displayed as alt-text below the attachment.
spoilerboolIf true, prepends SPOILER_ to the file name.

Construction

FileAttachment::new

pub fn new(name: impl Into<String>, data: Vec<u8>) -> Self
Creates an attachment with the given name and contents.
Panics if name is empty or data is empty.