aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrej <[email protected]>2018-02-02 13:30:25 +0100
committerZeyla Hellyer <[email protected]>2018-02-04 07:54:31 -0800
commite4c08b9ff01a9a2abbf0138ea9c85b9737857880 (patch)
tree885265bd67c804c92c0cc6c83339bdd663e738fa /src
parentBump to v0.5.1 (diff)
downloadserenity-e4c08b9ff01a9a2abbf0138ea9c85b9737857880.tar.xz
serenity-e4c08b9ff01a9a2abbf0138ea9c85b9737857880.zip
Add video url specifier for CreateEmbed (#269)
Diffstat (limited to 'src')
-rw-r--r--src/builder/create_embed.rs25
1 files changed, 14 insertions, 11 deletions
diff --git a/src/builder/create_embed.rs b/src/builder/create_embed.rs
index f420a8c..24a7513 100644
--- a/src/builder/create_embed.rs
+++ b/src/builder/create_embed.rs
@@ -164,26 +164,29 @@ impl CreateEmbed {
CreateEmbed(self.0)
}
- /// Set the image associated with the embed. This only supports HTTP(S).
- pub fn image(mut self, url: &str) -> Self {
- let image = json!({
+ fn url_object(mut self, name: &'static str, url: &str) -> Self {
+ let obj = json!({
"url": url.to_string()
});
- self.0.insert("image", image);
+ self.0.insert(name, obj);
CreateEmbed(self.0)
}
- /// Set the thumbnail of the embed. This only supports HTTP(S).
- pub fn thumbnail(mut self, url: &str) -> Self {
- let thumbnail = json!({
- "url": url.to_string(),
- });
+ /// Set the image associated with the embed. This only supports HTTP(S).
+ pub fn image(self, url: &str) -> Self {
+ self.url_object("image", url)
+ }
- self.0.insert("thumbnail", thumbnail);
+ /// Set the video associated with the embed. This only supports HTTP(S).
+ pub fn video(self, url: &str) -> Self {
+ self.url_object("video", url)
+ }
- CreateEmbed(self.0)
+ /// Set the thumbnail of the embed. This only supports HTTP(S).
+ pub fn thumbnail(self, url: &str) -> Self {
+ self.url_object("thumbnail", url)
}
/// Set the timestamp.