Document embed::ImageSource::attachment usage#2460
Document embed::ImageSource::attachment usage#2460lynn2910 wants to merge 4 commits intotwilight-rs:nextfrom
Conversation
There was a problem hiding this comment.
The notes I added to the book version should of course also be reflected in the mod file. After looking again I can see that it is only the book version that has these problems.
It should probably be marked to not run in the mod.rs file as a good example probably loaded the image from disk and we don't want to make the test read from the disk. We still want to make sure it builds though.
|
|
||
| let message = client | ||
| .create_message(channel_id) | ||
| .attachments(&[("bestpony.png".as_bytes(), "bestpony.png".to_owned(), 0)])? |
There was a problem hiding this comment.
This code is a bit wrong, you can no longer have the 3-tuple to make a attachment, instead you should use the Attachment struct.
So it should use Attachment::from_bytes(filename: String, file: Vec<[u8]>, id: u64) instead. The first field in the tuple (or file in Attachment::from_bytes) should be the actual image data.
| .attachments(&[("bestpony.png".as_bytes(), "bestpony.png".to_owned(), 0)])? | ||
| .embeds(&[embed.build()])? |
There was a problem hiding this comment.
attachments and embeds no longer return a result it it instead moved to the end.
Erk-
left a comment
There was a problem hiding this comment.
Some changes needed to bring the rustdoc version up to scratch
| /// .validate()? | ||
| /// .build(); | ||
| /// | ||
| /// // Then, send both the embed and the attachment with your message |
There was a problem hiding this comment.
I think some statements are missing below here.
| /// | ||
| /// Set the image source to a file attachment: | ||
| /// | ||
| /// ``` |
There was a problem hiding this comment.
| /// ``` | |
| /// ```no_run |
|
Please retarget this to |
Closes #2133
This PR has for purpose to address #2133, by adding documentation on how to send attachment file, other than URLs.