diff options
| author | Austin Hellyer <[email protected]> | 2016-11-15 20:40:53 -0800 |
|---|---|---|
| committer | Austin Hellyer <[email protected]> | 2016-11-15 20:40:53 -0800 |
| commit | 4de386549bd134236c254847374c81f0a1a18191 (patch) | |
| tree | 8fa5f22f1d6b44cd9c38c11740754999b1daf506 /src/client | |
| parent | Add send_message rich embeds (diff) | |
| download | serenity-4de386549bd134236c254847374c81f0a1a18191.tar.xz serenity-4de386549bd134236c254847374c81f0a1a18191.zip | |
Add message edit/edit_message rich embeds
Diffstat (limited to 'src/client')
| -rw-r--r-- | src/client/context.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/client/context.rs b/src/client/context.rs index fe69a57..1046361 100644 --- a/src/client/context.rs +++ b/src/client/context.rs @@ -6,6 +6,7 @@ use super::connection::Connection; use super::http; use super::login_type::LoginType; use ::utils::builder::{ + CreateEmbed, CreateInvite, CreateMessage, EditChannel, @@ -575,10 +576,17 @@ impl Context { http::edit_role(guild_id.0, role_id.0, map) } - pub fn edit_message<C, M>(&self, channel_id: C, message_id: M, text: &str) - -> Result<Message> where C: Into<ChannelId>, M: Into<MessageId> { + /// Edit a message given its Id and the Id of the channel it belongs to. + /// + /// Pass an empty string (`""`) to `text` if you are editing a message with + /// an embed but no content. Otherwise, `text` must be given. + pub fn edit_message<C, F, M>(&self, channel_id: C, message_id: M, text: &str, f: F) + -> Result<Message> where C: Into<ChannelId>, + F: FnOnce(CreateEmbed) -> CreateEmbed, + M: Into<MessageId> { let map = ObjectBuilder::new() .insert("content", text) + .insert("embed", Value::Object(f(CreateEmbed::default()).0)) .build(); http::edit_message(channel_id.into().0, message_id.into().0, map) |