aboutsummaryrefslogtreecommitdiff
path: root/src/model/channel/message.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2018-01-18 10:36:50 -0800
committerZeyla Hellyer <[email protected]>2018-01-18 10:36:50 -0800
commitedb76627d3fe292688b3c072c3d3f40db52e8aef (patch)
treeb37affd2a928d1845bdebe23a5456f7e3e878fd0 /src/model/channel/message.rs
parentUpdate readme example (diff)
downloadserenity-edb76627d3fe292688b3c072c3d3f40db52e8aef.tar.xz
serenity-edb76627d3fe292688b3c072c3d3f40db52e8aef.zip
Add an `EditMessage` builder
When editing messages, not all fields are applicable. Attachments, TTS, and reactions are not applicable. To help with this distinction, separate message editing into a different builder.
Diffstat (limited to 'src/model/channel/message.rs')
-rw-r--r--src/model/channel/message.rs16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs
index f3834bd..d8abf3d 100644
--- a/src/model/channel/message.rs
+++ b/src/model/channel/message.rs
@@ -5,7 +5,7 @@ use model::prelude::*;
use serde_json::Value;
#[cfg(feature = "model")]
-use builder::{CreateEmbed, CreateMessage};
+use builder::{CreateEmbed, EditMessage};
#[cfg(all(feature = "cache", feature = "model"))]
use CACHE;
#[cfg(all(feature = "cache", feature = "model"))]
@@ -178,7 +178,7 @@ impl Message {
///
/// Message editing preserves all unchanged message data.
///
- /// Refer to the documentation for [`CreateMessage`] for more information
+ /// Refer to the documentation for [`EditMessage`] for more information
/// regarding message restrictions and requirements.
///
/// **Note**: Requires that the current user be the author of the message.
@@ -204,10 +204,10 @@ impl Message {
///
/// [`ModelError::InvalidUser`]: enum.ModelError.html#variant.InvalidUser
/// [`ModelError::MessageTooLong`]: enum.ModelError.html#variant.MessageTooLong
- /// [`CreateMessage`]: ../builder/struct.CreateMessage.html
- /// [`the limit`]: ../builder/struct.CreateMessage.html#method.content
+ /// [`EditMessage`]: ../builder/struct.EditMessage.html
+ /// [`the limit`]: ../builder/struct.EditMessage.html#method.content
pub fn edit<F>(&mut self, f: F) -> Result<()>
- where F: FnOnce(CreateMessage) -> CreateMessage {
+ where F: FnOnce(EditMessage) -> EditMessage {
#[cfg(feature = "cache")]
{
if self.author.id != CACHE.read().user.id {
@@ -215,7 +215,7 @@ impl Message {
}
}
- let mut builder = CreateMessage::default();
+ let mut builder = EditMessage::default();
if !self.content.is_empty() {
builder = builder.content(&self.content);
@@ -225,10 +225,6 @@ impl Message {
builder = builder.embed(|_| CreateEmbed::from(embed.clone()));
}
- if self.tts {
- builder = builder.tts(true);
- }
-
let map = serenity_utils::vecmap_to_json_map(f(builder).0);
match http::edit_message(self.channel_id.0, self.id.0, &Value::Object(map)) {