diff options
| author | Zeyla Hellyer <[email protected]> | 2017-02-13 16:40:18 -0800 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-02-13 16:40:18 -0800 |
| commit | a0bb30686c1a9431aef23c2e8594791f64035194 (patch) | |
| tree | c09aef334fa4be10743020dbf111b96870e018e8 | |
| parent | Remove most Context methods (diff) | |
| download | serenity-a0bb30686c1a9431aef23c2e8594791f64035194.tar.xz serenity-a0bb30686c1a9431aef23c2e8594791f64035194.zip | |
Add 'say' to Group, GuildChannel, PrivateChannel
| -rw-r--r-- | src/client/context.rs | 2 | ||||
| -rw-r--r-- | src/model/channel.rs | 68 |
2 files changed, 62 insertions, 8 deletions
diff --git a/src/client/context.rs b/src/client/context.rs index d4744a4..2954d2c 100644 --- a/src/client/context.rs +++ b/src/client/context.rs @@ -1,7 +1,7 @@ use serde_json::builder::ObjectBuilder; use std::sync::{Arc, Mutex}; use super::gateway::Shard; -use super::rest::{self, GuildPagination}; +use super::rest; use super::login_type::LoginType; use typemap::ShareMap; use ::utils::builder::EditProfile; diff --git a/src/model/channel.rs b/src/model/channel.rs index 834fa9b..2c42405 100644 --- a/src/model/channel.rs +++ b/src/model/channel.rs @@ -330,6 +330,21 @@ impl Channel { } } + /// Sends a message with just the given message content in the channel. + /// + /// # Errors + /// + /// Returns a [`ClientError::MessageTooLong`] if the content of the message + /// is over the above limit, containing the number of unicode code points + /// over the limit. + /// + /// [`ChannelId`]: ../model/struct.ChannelId.html + /// [`ClientError::MessageTooLong`]: enum.ClientError.html#variant.MessageTooLong + #[inline] + pub fn say(&self, content: &str) -> Result<Message> { + self.id().say(content) + } + /// Performs a search request to the API for the inner channel's /// [`Message`]s. /// @@ -733,8 +748,7 @@ impl ChannelId { rest::get_pins(self.0) } - /// Sends a message with just the given message content in the channel that - /// a message was received from. + /// Sends a message with just the given message content in the channel. /// /// # Errors /// @@ -742,13 +756,8 @@ impl ChannelId { /// is over the above limit, containing the number of unicode code points /// over the limit. /// - /// Returns a [`ClientError::NoChannelId`] when there is no [`ChannelId`] - /// directly available; i.e. when not under the context of one of the above - /// events. - /// /// [`ChannelId`]: ../model/struct.ChannelId.html /// [`ClientError::MessageTooLong`]: enum.ClientError.html#variant.MessageTooLong - /// [`ClientError::NoChannelId`]: enum.ClientError.html#NoChannelId #[inline] pub fn say(&self, content: &str) -> Result<Message> { self.send_message(|m| m.content(content)) @@ -1115,6 +1124,21 @@ impl Group { rest::remove_group_recipient(self.channel_id.0, user.0) } + /// Sends a message with just the given message content in the channel. + /// + /// # Errors + /// + /// Returns a [`ClientError::MessageTooLong`] if the content of the message + /// is over the above limit, containing the number of unicode code points + /// over the limit. + /// + /// [`ChannelId`]: ../model/struct.ChannelId.html + /// [`ClientError::MessageTooLong`]: enum.ClientError.html#variant.MessageTooLong + #[inline] + pub fn say(&self, content: &str) -> Result<Message> { + self.channel_id.say(content) + } + /// Performs a search request to the API for the group's channel's /// [`Message`]s. /// @@ -1718,6 +1742,21 @@ impl PrivateChannel { self.id.pins() } + /// Sends a message with just the given message content in the channel. + /// + /// # Errors + /// + /// Returns a [`ClientError::MessageTooLong`] if the content of the message + /// is over the above limit, containing the number of unicode code points + /// over the limit. + /// + /// [`ChannelId`]: ../model/struct.ChannelId.html + /// [`ClientError::MessageTooLong`]: enum.ClientError.html#variant.MessageTooLong + #[inline] + pub fn say(&self, content: &str) -> Result<Message> { + self.id.say(content) + } + /// Performs a search request to the API for the channel's [`Message`]s. /// /// Refer to the documentation for the [`Search`] builder for examples and @@ -2136,6 +2175,21 @@ impl GuildChannel { self.id.pins() } + /// Sends a message with just the given message content in the channel. + /// + /// # Errors + /// + /// Returns a [`ClientError::MessageTooLong`] if the content of the message + /// is over the above limit, containing the number of unicode code points + /// over the limit. + /// + /// [`ChannelId`]: ../model/struct.ChannelId.html + /// [`ClientError::MessageTooLong`]: enum.ClientError.html#variant.MessageTooLong + #[inline] + pub fn say(&self, content: &str) -> Result<Message> { + self.id.say(content) + } + /// Performs a search request for the channel's [`Message`]s. /// /// Refer to the documentation for the [`Search`] builder for examples and |