aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrandon Lucier <[email protected]>2018-03-04 03:48:37 -0800
committeralex <[email protected]>2018-03-04 12:48:37 +0100
commit7e0d9082fe0262c7b4c4668ca1e1208dffa4796f (patch)
treee325f2d0d134f0fb3a34a350f554d40f20f69b96 /src
parentFix formatting (diff)
downloadserenity-7e0d9082fe0262c7b4c4668ca1e1208dffa4796f.tar.xz
serenity-7e0d9082fe0262c7b4c4668ca1e1208dffa4796f.zip
Support sending files with an embed (#285)
Diffstat (limited to 'src')
-rw-r--r--src/http/mod.rs1
-rw-r--r--src/model/channel/channel_id.rs9
2 files changed, 5 insertions, 5 deletions
diff --git a/src/http/mod.rs b/src/http/mod.rs
index e40b3c6..30d42e9 100644
--- a/src/http/mod.rs
+++ b/src/http/mod.rs
@@ -1734,6 +1734,7 @@ pub fn send_files<'a, T, It: IntoIterator<Item=T>>(channel_id: u64, files: It, m
Value::Bool(true) => request.write_text(&k, "true")?,
Value::Number(inner) => request.write_text(&k, inner.to_string())?,
Value::String(inner) => request.write_text(&k, inner)?,
+ Value::Object(inner) => request.write_text(&k, serde_json::to_string(&inner)?)?,
_ => continue,
};
}
diff --git a/src/model/channel/channel_id.rs b/src/model/channel/channel_id.rs
index 00dc1f2..d460190 100644
--- a/src/model/channel/channel_id.rs
+++ b/src/model/channel/channel_id.rs
@@ -406,9 +406,6 @@ impl ChannelId {
/// Message contents may be passed by using the [`CreateMessage::content`]
/// method.
///
- /// An embed can _not_ be sent when sending a file. If you set one, it will
- /// be automatically removed.
- ///
/// The [Attach Files] and [Send Messages] permissions are required.
///
/// **Note**: Message contents must be under 2000 unicode code points.
@@ -472,9 +469,11 @@ impl ChannelId {
}
}
- let _ = msg.0.remove(&"embed");
- let map = utils::vecmap_to_json_map(msg.0);
+ if let Some(e) = msg.0.remove(&"embed") {
+ msg.0.insert("payload_json", json!({ "embed": e }));
+ }
+ let map = utils::vecmap_to_json_map(msg.0);
http::send_files(self.0, files, map)
}