Open keiveulbugs opened 6 months ago
You can create an attachment an attach it as such
let img_path: &Path = Path::new("./img.png");
let attachment_bytes: Vec<u8> = std::fs::read(img_path).expect("Failed to read card file");
let attachment: CreateAttachment = CreateAttachment::bytes(
attachment_bytes,
"img.png"
);
// attachment can be routed thru an embed aswell
CreateMessage::default()
.add_file(attachment)
.content("@everyone")
This seems correct, not sure why the docs say it only supports HTTPS for those methods. CreateEmbed::attachment
even specifies CreateEmbed::image
works with local attachments by using the attachment://
syntax. So do the Discord docs.
In the documentation it states that the Footer, Thumbnail & Image only support HTTP(S).
https://docs.rs/serenity/latest/serenity/builder/struct.CreateEmbed.html#method.image https://docs.rs/serenity/latest/serenity/builder/struct.CreateEmbed.html#method.thumbnail https://docs.rs/serenity/latest/serenity/builder/struct.CreateEmbedFooter.html#method.icon_url
This is a bit misleading as you can use local files when attached to the message. I tried fixing the docs, but have not a setup ready at the moment to test if the docs are working and if it works in pure Serenity. (In poise it works, but uses the
CreateReply
function.)Would love if someone could check this and add something to the docs about how to use local files.