diff options
| author | alex <[email protected]> | 2017-05-25 01:36:59 +0200 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-05-24 16:36:59 -0700 |
| commit | 77b5b480d67e747908f8f4fb9f910bab23b761b5 (patch) | |
| tree | a8f62266916a0dbefac576c14f6de189c07159db /src/model | |
| parent | Add more examples and improve some others (diff) | |
| download | serenity-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/model')
| -rw-r--r-- | src/model/channel/channel_id.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/model/channel/channel_id.rs b/src/model/channel/channel_id.rs index 3967dba..76fe6f7 100644 --- a/src/model/channel/channel_id.rs +++ b/src/model/channel/channel_id.rs @@ -425,12 +425,20 @@ impl ChannelId { /// [Send Messages]: permissions/constant.SEND_MESSAGES.html pub fn send_message<F>(&self, f: F) -> Result<Message> where F: FnOnce(CreateMessage) -> CreateMessage { - let map = f(CreateMessage::default()).0; + let CreateMessage(map, reactions) = f(CreateMessage::default()); Message::check_content_length(&map)?; Message::check_embed_length(&map)?; - http::send_message(self.0, &Value::Object(map)) + let message = http::send_message(self.0, &Value::Object(map))?; + + if let Some(reactions) = reactions { + for reaction in reactions { + self.create_reaction(message.id, reaction)?; + } + } + + Ok(message) } /// Unpins a [`Message`] in the channel given by its Id. |