aboutsummaryrefslogtreecommitdiff
path: root/src/builder/create_message.rs
diff options
context:
space:
mode:
authoralex <[email protected]>2017-05-25 01:36:59 +0200
committerZeyla Hellyer <[email protected]>2017-05-24 16:36:59 -0700
commit77b5b480d67e747908f8f4fb9f910bab23b761b5 (patch)
treea8f62266916a0dbefac576c14f6de189c07159db /src/builder/create_message.rs
parentAdd more examples and improve some others (diff)
downloadserenity-77b5b480d67e747908f8f4fb9f910bab23b761b5.tar.xz
serenity-77b5b480d67e747908f8f4fb9f910bab23b761b5.zip
Support adding reactions when creating message
These reactions are added onto the `MessageCreate` builder, and are sent after the message has been created.
Diffstat (limited to 'src/builder/create_message.rs')
-rw-r--r--src/builder/create_message.rs18
1 files changed, 13 insertions, 5 deletions
diff --git a/src/builder/create_message.rs b/src/builder/create_message.rs
index 9a2349a..14be4ca 100644
--- a/src/builder/create_message.rs
+++ b/src/builder/create_message.rs
@@ -1,4 +1,5 @@
use super::CreateEmbed;
+use ::model::ReactionType;
use ::internal::prelude::*;
/// A builder to specify the contents of an [`http::send_message`] request,
@@ -37,7 +38,7 @@ use ::internal::prelude::*;
/// [`embed`]: #method.embed
/// [`http::send_message`]: ../http/fn.send_message.html
#[derive(Clone, Debug)]
-pub struct CreateMessage(pub Map<String, Value>);
+pub struct CreateMessage(pub Map<String, Value>, pub Option<Vec<ReactionType>>);
impl CreateMessage {
/// Set the content of the message.
@@ -46,7 +47,7 @@ impl CreateMessage {
pub fn content(mut self, content: &str) -> Self {
self.0.insert("content".to_owned(), Value::String(content.to_owned()));
- CreateMessage(self.0)
+ CreateMessage(self.0, self.1)
}
/// Set an embed for the message.
@@ -56,7 +57,7 @@ impl CreateMessage {
self.0.insert("embed".to_owned(), embed);
- CreateMessage(self.0)
+ CreateMessage(self.0, self.1)
}
/// Set whether the message is text-to-speech.
@@ -67,7 +68,14 @@ impl CreateMessage {
pub fn tts(mut self, tts: bool) -> Self {
self.0.insert("tts".to_owned(), Value::Bool(tts));
- CreateMessage(self.0)
+ CreateMessage(self.0, self.1)
+ }
+
+ /// Adds a list of reactions to create after the message's sent.
+ pub fn reactions<R: Into<ReactionType>>(mut self, reactions: Vec<R>) -> Self {
+ self.1 = Some(reactions.into_iter().map(|r| r.into()).collect());
+
+ CreateMessage(self.0, self.1)
}
}
@@ -81,6 +89,6 @@ impl Default for CreateMessage {
let mut map = Map::default();
map.insert("tts".to_owned(), Value::Bool(false));
- CreateMessage(map)
+ CreateMessage(map, None)
}
}