aboutsummaryrefslogtreecommitdiff
path: root/src/model/channel/group.rs
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-04-13 20:45:56 -0700
committerZeyla Hellyer <[email protected]>2017-04-19 14:53:32 -0700
commit3f03f9adc97315bb61a5c71f52365306cb8e2d1a (patch)
tree8fe0b518d1450b0657cfb75f56251fd90120807e /src/model/channel/group.rs
parentUpdate the way errors are handled in dispatch (diff)
downloadserenity-3f03f9adc97315bb61a5c71f52365306cb8e2d1a.tar.xz
serenity-3f03f9adc97315bb61a5c71f52365306cb8e2d1a.zip
Deprecate methods prefixed with `get_`
A lot of structs - such as `Guild` or `ChannelId` - have methods with prefixes of `get_`, which are generally discouraged. To fix this, deprecate them and remove them in v0.3.0.
Diffstat (limited to 'src/model/channel/group.rs')
-rw-r--r--src/model/channel/group.rs109
1 files changed, 71 insertions, 38 deletions
diff --git a/src/model/channel/group.rs b/src/model/channel/group.rs
index 21e9606..b85bc7d 100644
--- a/src/model/channel/group.rs
+++ b/src/model/channel/group.rs
@@ -143,14 +143,26 @@ impl Group {
self.channel_id.edit_message(message_id, f)
}
+ /// Returns the formatted URI of the group's icon if one exists.
+ pub fn icon_url(&self) -> Option<String> {
+ self.icon.as_ref().map(|icon|
+ format!(cdn!("/channel-icons/{}/{}.webp"), self.channel_id, icon))
+ }
+
+ /// Leaves the group.
+ #[inline]
+ pub fn leave(&self) -> Result<Group> {
+ rest::leave_group(self.channel_id.0)
+ }
+
/// Gets a message from the channel.
///
/// Requires the [Read Message History] permission.
///
/// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html
#[inline]
- pub fn get_message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message> {
- self.channel_id.get_message(message_id)
+ pub fn message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message> {
+ self.channel_id.message(message_id)
}
/// Gets messages from the channel.
@@ -159,43 +171,9 @@ impl Group {
///
/// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html
#[inline]
- pub fn get_messages<F>(&self, f: F) -> Result<Vec<Message>>
+ pub fn messages<F>(&self, f: F) -> Result<Vec<Message>>
where F: FnOnce(GetMessages) -> GetMessages {
- self.channel_id.get_messages(f)
- }
-
- /// Gets the list of [`User`]s who have reacted to a [`Message`] with a
- /// certain [`Emoji`].
- ///
- /// Refer to [`Channel::get_reaction_users`] for more information.
- ///
- /// **Note**: Requires the [Read Message History] permission.
- ///
- /// [`Channel::get_reaction_users`]: enum.Channel.html#variant.get_reaction_users
- /// [`Emoji`]: struct.Emoji.html
- /// [`Message`]: struct.Message.html
- /// [`User`]: struct.User.html
- /// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html
- #[inline]
- pub fn get_reaction_users<M, R, U>(&self,
- message_id: M,
- reaction_type: R,
- limit: Option<u8>,
- after: Option<U>)
- -> Result<Vec<User>> where M: Into<MessageId>, R: Into<ReactionType>, U: Into<UserId> {
- self.channel_id.get_reaction_users(message_id, reaction_type, limit, after)
- }
-
- /// Returns the formatted URI of the group's icon if one exists.
- pub fn icon_url(&self) -> Option<String> {
- self.icon.as_ref().map(|icon|
- format!(cdn!("/channel-icons/{}/{}.webp"), self.channel_id, icon))
- }
-
- /// Leaves the group.
- #[inline]
- pub fn leave(&self) -> Result<Group> {
- rest::leave_group(self.channel_id.0)
+ self.channel_id.messages(f)
}
/// Generates a name for the group.
@@ -227,6 +205,28 @@ impl Group {
self.channel_id.pins()
}
+ /// Gets the list of [`User`]s who have reacted to a [`Message`] with a
+ /// certain [`Emoji`].
+ ///
+ /// Refer to [`Channel::get_reaction_users`] for more information.
+ ///
+ /// **Note**: Requires the [Read Message History] permission.
+ ///
+ /// [`Channel::get_reaction_users`]: enum.Channel.html#variant.get_reaction_users
+ /// [`Emoji`]: struct.Emoji.html
+ /// [`Message`]: struct.Message.html
+ /// [`User`]: struct.User.html
+ /// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html
+ #[inline]
+ pub fn reaction_users<M, R, U>(&self,
+ message_id: M,
+ reaction_type: R,
+ limit: Option<u8>,
+ after: Option<U>)
+ -> Result<Vec<User>> where M: Into<MessageId>, R: Into<ReactionType>, U: Into<UserId> {
+ self.channel_id.reaction_users(message_id, reaction_type, limit, after)
+ }
+
/// Removes a recipient from the group. If the recipient is already not in
/// the group, then nothing is done.
///
@@ -305,4 +305,37 @@ impl Group {
pub fn unpin<M: Into<MessageId>>(&self, message_id: M) -> Result<()> {
self.channel_id.unpin(message_id)
}
+
+ /// Alias of [`message`].
+ ///
+ /// [`message`]: #method.message
+ #[deprecated(since="0.1.5", note="Use `message` instead.")]
+ #[inline]
+ pub fn get_message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message> {
+ self.message(message_id)
+ }
+
+ /// Alias of [`messages`].
+ ///
+ /// [`messages`]: #method.messages
+ #[deprecated(since="0.1.5", note="Use `messages` instead.")]
+ #[inline]
+ pub fn get_messages<F>(&self, f: F) -> Result<Vec<Message>>
+ where F: FnOnce(GetMessages) -> GetMessages {
+ self.messages(f)
+ }
+
+ /// Alias of [`reaction_users`].
+ ///
+ /// [`reaction_users`]: #method.reaction_users
+ #[deprecated(since="0.1.5", note="Use `reaction_users` instead.")]
+ #[inline]
+ pub fn get_reaction_users<M, R, U>(&self,
+ message_id: M,
+ reaction_type: R,
+ limit: Option<u8>,
+ after: Option<U>)
+ -> Result<Vec<User>> where M: Into<MessageId>, R: Into<ReactionType>, U: Into<UserId> {
+ self.reaction_users(message_id, reaction_type, limit, after)
+ }
}