diff options
| author | Austin Hellyer <[email protected]> | 2016-12-18 20:55:36 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-12-18 20:55:36 -0800 |
| commit | 68c473dd17a2098f97808b3d1f2a200621f67c9d (patch) | |
| tree | 8b8f930cf3049649ab5a022edc36248f714a8878 /src | |
| parent | Fix a typo in UserId::find docs (diff) | |
| download | serenity-68c473dd17a2098f97808b3d1f2a200621f67c9d.tar.xz serenity-68c473dd17a2098f97808b3d1f2a200621f67c9d.zip | |
Remove image/thumbnail embed builders
When implemented, it was thought that images and thumbnails would be
able to have their height/width specified. This isn't the case, and so
the image/height methods were deprecated on the builders. Time has
passed, so just remove them in favour of direct methods on CreateEmbed
instead.
Diffstat (limited to 'src')
| -rw-r--r-- | src/utils/builder/create_embed.rs | 95 | ||||
| -rw-r--r-- | src/utils/builder/mod.rs | 2 |
2 files changed, 13 insertions, 84 deletions
diff --git a/src/utils/builder/create_embed.rs b/src/utils/builder/create_embed.rs index e311dc3..d33db8a 100644 --- a/src/utils/builder/create_embed.rs +++ b/src/utils/builder/create_embed.rs @@ -129,30 +129,22 @@ impl CreateEmbed { CreateEmbed(self.0) } - /// Set the image associated with the embed. - /// - /// Refer to the documentation for [`CreateEmbedImage`] for more - /// information. - /// - /// [`CreateEmbedImage`]: struct.CreateEmbedImage.html - pub fn image<F>(mut self, f: F) -> Self - where F: FnOnce(CreateEmbedImage) -> CreateEmbedImage { - let image = f(CreateEmbedImage::default()).0.build(); + /// Set the image associated with the embed. This only supports HTTP(S). + pub fn image(mut self, url: &str) -> Self { + let image = ObjectBuilder::new() + .insert("url".to_owned(), url.to_owned()) + .build(); self.0.insert("image".to_owned(), image); CreateEmbed(self.0) } - /// Set the thumbnail of the embed. - /// - /// Refer to the documentation for [`CreateEmbedThumbnail`] for more - /// information. - /// - /// [`CreateEmbedThumbnail`]: struct.CreateEmbedThumbnail.html - pub fn thumbnail<F>(mut self, f: F) -> Self - where F: FnOnce(CreateEmbedThumbnail) -> CreateEmbedThumbnail { - let thumbnail = f(CreateEmbedThumbnail::default()).0.build(); + /// Set the thumbnail of the embed. This only supports HTTP(S). + pub fn thumbnail(mut self, url: &str) -> Self { + let thumbnail = ObjectBuilder::new() + .insert("url".to_owned(), url.to_owned()) + .build(); self.0.insert("thumbnail".to_owned(), thumbnail); @@ -174,7 +166,7 @@ impl CreateEmbed { /// /// Or a `time::Tm`: /// - /// ```rust,no_run + /// ```rust,ignore /// extern crate time; /// /// let now = time::now(); @@ -251,7 +243,7 @@ impl From<Embed> for CreateEmbed { } if let Some(image) = embed.image { - b = b.image(move |i| i.url(&image.url)); + b = b.image(&image.url); } if let Some(timestamp) = embed.timestamp { @@ -259,7 +251,7 @@ impl From<Embed> for CreateEmbed { } if let Some(thumbnail) = embed.thumbnail { - b = b.thumbnail(move |t| t.url(&thumbnail.url)); + b = b.thumbnail(&thumbnail.url); } if let Some(url) = embed.url { @@ -360,67 +352,6 @@ impl CreateEmbedFooter { } } -/// A builder to create a fake [`Embed`] object's image, for use with the -/// [`CreateEmbed::image`] method. -/// -/// This does not require any field be set. -/// -/// [`Embed`]: ../../model/struct.Embed.html -/// [`CreateEmbed::image`]: struct.CreateEmbed.html#method.image -#[derive(Default)] -pub struct CreateEmbedImage(pub ObjectBuilder); - -impl CreateEmbedImage { - /// Set the display height of the image. - #[deprecated(since="0.1.2", note="Discord does not allow specifying this")] - pub fn height(self, height: u64) -> Self { - CreateEmbedImage(self.0.insert("height", height)) - } - - /// Set the image's URL. This only supports HTTP(S). - pub fn url(self, url: &str) -> Self { - CreateEmbedImage(self.0.insert("url", url)) - } - - /// Set the display width of the image. - #[deprecated(since="0.1.2", note="Discord does not allow specifying this")] - pub fn width(self, width: u64) -> Self { - CreateEmbedImage(self.0.insert("width", width)) - } -} - -/// A builder to create a fake [`Embed`] object's thumbnail, for use with the -/// [`CreateEmbed::thumbnail`] method. -/// -/// Requires that you specify a [`url`]. -/// -/// [`Embed`]: ../../model/struct.Embed.html -/// [`CreateEmbed::thumbnail`]: struct.CreateEmbed.html#method.thumbnail -/// [`url`]: #method.url -#[derive(Default)] -pub struct CreateEmbedThumbnail(pub ObjectBuilder); - -impl CreateEmbedThumbnail { - /// Set the height of the thumbnail, in pixels. - #[deprecated(since="0.1.2", note="Discord does not allow specifying this")] - pub fn height(self, height: u64) -> Self { - CreateEmbedThumbnail(self.0.insert("height", height)) - } - - /// Set the URL of the thumbnail. This only supports HTTP(S). - /// - /// _Must_ be specified. - pub fn url(self, url: &str) -> Self { - CreateEmbedThumbnail(self.0.insert("url", url)) - } - - /// Set the width of the thumbnail, in pixels. - #[deprecated(since="0.1.2", note="Discord does not allow specifying this")] - pub fn width(self, width: u64) -> Self { - CreateEmbedThumbnail(self.0.insert("width", width)) - } -} - pub struct Timestamp { pub ts: String, } diff --git a/src/utils/builder/mod.rs b/src/utils/builder/mod.rs index 497d309..3fc0f05 100644 --- a/src/utils/builder/mod.rs +++ b/src/utils/builder/mod.rs @@ -21,8 +21,6 @@ pub use self::create_embed::{ CreateEmbedAuthor, CreateEmbedFooter, CreateEmbedField, - CreateEmbedImage, - CreateEmbedThumbnail, }; pub use self::create_invite::CreateInvite; pub use self::create_message::CreateMessage; |