diff options
| author | Zeyla Hellyer <[email protected]> | 2017-04-13 20:45:56 -0700 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-04-19 14:53:32 -0700 |
| commit | 3f03f9adc97315bb61a5c71f52365306cb8e2d1a (patch) | |
| tree | 8fe0b518d1450b0657cfb75f56251fd90120807e /src/model/channel | |
| parent | Update the way errors are handled in dispatch (diff) | |
| download | serenity-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')
| -rw-r--r-- | src/model/channel/channel_id.rs | 115 | ||||
| -rw-r--r-- | src/model/channel/group.rs | 109 | ||||
| -rw-r--r-- | src/model/channel/guild_channel.rs | 137 | ||||
| -rw-r--r-- | src/model/channel/message.rs | 20 | ||||
| -rw-r--r-- | src/model/channel/mod.rs | 53 | ||||
| -rw-r--r-- | src/model/channel/private_channel.rs | 53 |
6 files changed, 349 insertions, 138 deletions
diff --git a/src/model/channel/channel_id.rs b/src/model/channel/channel_id.rs index f0834de..5b238b0 100644 --- a/src/model/channel/channel_id.rs +++ b/src/model/channel/channel_id.rs @@ -222,7 +222,7 @@ impl ChannelId { /// Search the cache for the channel with the Id. #[cfg(feature="cache")] pub fn find(&self) -> Option<Channel> { - CACHE.read().unwrap().get_channel(*self) + CACHE.read().unwrap().channel(*self) } /// Search the cache for the channel. If it can't be found, the channel is @@ -230,7 +230,7 @@ impl ChannelId { pub fn get(&self) -> Result<Channel> { #[cfg(feature="cache")] { - if let Some(channel) = CACHE.read().unwrap().get_channel(*self) { + if let Some(channel) = CACHE.read().unwrap().channel(*self) { return Ok(channel); } } @@ -243,7 +243,7 @@ impl ChannelId { /// Requires the [Manage Channels] permission. /// [Manage Channels]: permissions/constant.MANAGE_CHANNELS.html #[inline] - pub fn get_invites(&self) -> Result<Vec<RichInvite>> { + pub fn invites(&self) -> Result<Vec<RichInvite>> { rest::get_channel_invites(self.0) } @@ -253,7 +253,7 @@ impl ChannelId { /// /// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html #[inline] - pub fn get_message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message> { + pub fn message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message> { rest::get_message(self.0, message_id.into().0) } @@ -265,7 +265,7 @@ impl ChannelId { /// /// [`Channel::get_messages`]: enum.Channel.html#method.get_messages /// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html - 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 { let mut map = f(GetMessages::default()).0; let mut query = format!("?limit={}", map.remove("limit").unwrap_or(50)); @@ -281,6 +281,22 @@ impl ChannelId { rest::get_messages(self.0, &query) } + /// Pins a [`Message`] to the channel. + /// + /// [`Message`]: struct.Message.html + #[inline] + pub fn pin<M: Into<MessageId>>(&self, message_id: M) -> Result<()> { + rest::pin_message(self.0, message_id.into().0) + } + + /// Gets the list of [`Message`]s which are pinned to the channel. + /// + /// [`Message`]: struct.Message.html + #[inline] + pub fn pins(&self) -> Result<Vec<Message>> { + rest::get_pins(self.0) + } + /// Gets the list of [`User`]s who have reacted to a [`Message`] with a /// certain [`Emoji`]. /// @@ -293,7 +309,7 @@ impl ChannelId { /// [`Message`]: struct.Message.html /// [`User`]: struct.User.html /// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html - pub fn get_reaction_users<M, R, U>(&self, + pub fn reaction_users<M, R, U>(&self, message_id: M, reaction_type: R, limit: Option<u8>, @@ -308,32 +324,6 @@ impl ChannelId { after.map(|u| u.into().0)) } - /// Retrieves the channel's webhooks. - /// - /// **Note**: Requires the [Manage Webhooks] permission. - /// - /// [Manage Webhooks]: permissions/constant.MANAGE_WEBHOOKS.html - #[inline] - pub fn get_webhooks(&self) -> Result<Vec<Webhook>> { - rest::get_channel_webhooks(self.0) - } - - /// Pins a [`Message`] to the channel. - /// - /// [`Message`]: struct.Message.html - #[inline] - pub fn pin<M: Into<MessageId>>(&self, message_id: M) -> Result<()> { - rest::pin_message(self.0, message_id.into().0) - } - - /// Gets the list of [`Message`]s which are pinned to the channel. - /// - /// [`Message`]: struct.Message.html - #[inline] - pub fn pins(&self) -> Result<Vec<Message>> { - rest::get_pins(self.0) - } - /// Sends a message with just the given message content in the channel. /// /// # Errors @@ -449,6 +439,67 @@ impl ChannelId { pub fn unpin<M: Into<MessageId>>(&self, message_id: M) -> Result<()> { rest::unpin_message(self.0, message_id.into().0) } + + /// Retrieves the channel's webhooks. + /// + /// **Note**: Requires the [Manage Webhooks] permission. + /// + /// [Manage Webhooks]: permissions/constant.MANAGE_WEBHOOKS.html + #[inline] + pub fn webhooks(&self) -> Result<Vec<Webhook>> { + rest::get_channel_webhooks(self.0) + } + + /// Alias of [`invites`]. + /// + /// [`invites`]: #method.invites + #[deprecated(since="0.1.5", note="Use `invites` instead.")] + #[inline] + pub fn get_invites(&self) -> Result<Vec<RichInvite>> { + self.invites() + } + + /// 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) + } + + /// Alias of [`webhooks`]. + /// + /// [`webhooks`]: #method.webhooks + #[deprecated(since="0.1.5", note="Use `webhooks` instead.")] + #[inline] + pub fn get_webhooks(&self) -> Result<Vec<Webhook>> { + self.webhooks() + } } impl From<Channel> for ChannelId { 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) + } } diff --git a/src/model/channel/guild_channel.rs b/src/model/channel/guild_channel.rs index eaefb70..6cbdda0 100644 --- a/src/model/channel/guild_channel.rs +++ b/src/model/channel/guild_channel.rs @@ -301,13 +301,22 @@ impl GuildChannel { self.id.edit_message(message_id, f) } + /// Attempts to find this channel's guild in the Cache. + /// + /// **Note**: Right now this performs a clone of the guild. This will be + /// optimized in the future. + #[cfg(feature="cache")] + pub fn guild(&self) -> Option<Arc<RwLock<Guild>>> { + CACHE.read().unwrap().guild(self.guild_id) + } + /// Gets all of the channel's invites. /// /// Requires the [Manage Channels] permission. /// [Manage Channels]: permissions/constant.MANAGE_CHANNELS.html #[inline] - pub fn get_invites(&self) -> Result<Vec<RichInvite>> { - self.id.get_invites() + pub fn invites(&self) -> Result<Vec<RichInvite>> { + self.id.invites() } /// Gets a message from the channel. @@ -316,8 +325,8 @@ impl GuildChannel { /// /// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html #[inline] - pub fn get_message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message> { - self.id.get_message(message_id) + pub fn message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message> { + self.id.message(message_id) } /// Gets messages from the channel. @@ -329,9 +338,21 @@ impl GuildChannel { /// [`Channel::get_messages`]: enum.Channel.html#method.get_messages /// [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.id.get_messages(f) + self.id.messages(f) + } + + /// Pins a [`Message`] to the channel. + #[inline] + pub fn pin<M: Into<MessageId>>(&self, message_id: M) -> Result<()> { + self.id.pin(message_id) + } + + /// Gets all channel's pins. + #[inline] + pub fn pins(&self) -> Result<Vec<Message>> { + self.id.pins() } /// Gets the list of [`User`]s who have reacted to a [`Message`] with a @@ -346,44 +367,13 @@ impl GuildChannel { /// [`Message`]: struct.Message.html /// [`User`]: struct.User.html /// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html - pub fn get_reaction_users<M, R, U>(&self, - message_id: M, - reaction_type: R, - limit: Option<u8>, - after: Option<U>) + 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.id.get_reaction_users(message_id, reaction_type, limit, after) - } - - /// Retrieves the channel's webhooks. - /// - /// **Note**: Requires the [Manage Webhooks] permission. - /// - /// [Manage Webhooks]: permissions/constant.MANAGE_WEBHOOKS.html - #[inline] - pub fn get_webhooks(&self) -> Result<Vec<Webhook>> { - self.id.get_webhooks() - } - - /// Attempts to find this channel's guild in the Cache. - /// - /// **Note**: Right now this performs a clone of the guild. This will be - /// optimized in the future. - #[cfg(feature="cache")] - pub fn guild(&self) -> Option<Arc<RwLock<Guild>>> { - CACHE.read().unwrap().get_guild(self.guild_id) - } - - /// Pins a [`Message`] to the channel. - #[inline] - pub fn pin<M: Into<MessageId>>(&self, message_id: M) -> Result<()> { - self.id.pin(message_id) - } - - /// Gets all channel's pins. - #[inline] - pub fn pins(&self) -> Result<Vec<Message>> { - self.id.pins() + self.id.reaction_users(message_id, reaction_type, limit, after) } /// Sends a message with just the given message content in the channel. @@ -467,6 +457,67 @@ impl GuildChannel { pub fn unpin<M: Into<MessageId>>(&self, message_id: M) -> Result<()> { self.id.unpin(message_id) } + + /// Retrieves the channel's webhooks. + /// + /// **Note**: Requires the [Manage Webhooks] permission. + /// + /// [Manage Webhooks]: permissions/constant.MANAGE_WEBHOOKS.html + #[inline] + pub fn webhooks(&self) -> Result<Vec<Webhook>> { + self.id.webhooks() + } + + /// Alias of [`invites`]. + /// + /// [`invites`]: #method.invites + #[deprecated(since="0.1.5", note="Use `invites` instead.")] + #[inline] + pub fn get_invites(&self) -> Result<Vec<RichInvite>> { + self.invites() + } + + /// 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) + } + + /// Alias of [`webhooks`]. + /// + /// [`webhooks`]: #method.webhooks + #[deprecated(since="0.1.5", note="Use `webhooks` instead.")] + #[inline] + pub fn get_webhooks(&self) -> Result<Vec<Webhook>> { + self.webhooks() + } } impl Display for GuildChannel { diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs index f572aea..6bbb1a2 100644 --- a/src/model/channel/message.rs +++ b/src/model/channel/message.rs @@ -236,9 +236,9 @@ impl Message { /// [`User`]: struct.User.html /// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html #[inline] - pub fn get_reaction_users<R, U>(&self, reaction_type: R, limit: Option<u8>, after: Option<U>) + pub fn reaction_users<R, U>(&self, reaction_type: R, limit: Option<u8>, after: Option<U>) -> Result<Vec<User>> where R: Into<ReactionType>, U: Into<UserId> { - self.channel_id.get_reaction_users(self.id, reaction_type, limit, after) + self.channel_id.reaction_users(self.id, reaction_type, limit, after) } /// Returns the associated `Guild` for the message if one is in the cache. @@ -251,7 +251,7 @@ impl Message { /// [`guild_id`]: #method.guild_id #[cfg(feature="cache")] pub fn guild(&self) -> Option<Arc<RwLock<Guild>>> { - self.guild_id().and_then(|guild_id| CACHE.read().unwrap().get_guild(guild_id)) + self.guild_id().and_then(|guild_id| CACHE.read().unwrap().guild(guild_id)) } /// Retrieves the Id of the guild that the message was sent in, if sent in @@ -261,7 +261,7 @@ impl Message { /// cache. #[cfg(feature="cache")] pub fn guild_id(&self) -> Option<GuildId> { - match CACHE.read().unwrap().get_channel(self.channel_id) { + match CACHE.read().unwrap().channel(self.channel_id) { Some(Channel::Guild(ch)) => Some(ch.read().unwrap().guild_id), _ => None, } @@ -270,7 +270,7 @@ impl Message { /// True if message was sent using direct messages. #[cfg(feature="cache")] pub fn is_private(&self) -> bool { - match CACHE.read().unwrap().get_channel(self.channel_id) { + match CACHE.read().unwrap().channel(self.channel_id) { Some(Channel::Group(_)) | Some(Channel::Private(_)) => true, _ => false, } @@ -421,6 +421,16 @@ impl Message { rest::unpin_message(self.channel_id.0, self.id.0) } + + /// 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<R, U>(&self, reaction_type: R, limit: Option<u8>, after: Option<U>) + -> Result<Vec<User>> where R: Into<ReactionType>, U: Into<UserId> { + self.reaction_users(reaction_type, limit, after) + } } impl From<Message> for MessageId { diff --git a/src/model/channel/mod.rs b/src/model/channel/mod.rs index 4877785..2ad06cf 100644 --- a/src/model/channel/mod.rs +++ b/src/model/channel/mod.rs @@ -170,8 +170,8 @@ impl Channel { /// /// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html #[inline] - pub fn get_message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message> { - self.id().get_message(message_id) + pub fn message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message> { + self.id().message(message_id) } /// Gets messages from the channel. @@ -191,9 +191,9 @@ impl Channel { /// /// [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.id().get_messages(f) + self.id().messages(f) } /// Gets the list of [`User`]s who have reacted to a [`Message`] with a @@ -213,13 +213,13 @@ impl Channel { /// [`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>) + 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.id().get_reaction_users(message_id, reaction_type, limit, after) + self.id().reaction_users(message_id, reaction_type, limit, after) } /// Retrieves the Id of the inner [`Group`], [`GuildChannel`], or @@ -310,6 +310,39 @@ impl Channel { pub fn unpin<M: Into<MessageId>>(&self, message_id: M) -> Result<()> { self.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) + } } impl Deserialize for Channel { diff --git a/src/model/channel/private_channel.rs b/src/model/channel/private_channel.rs index 802f84a..2ede408 100644 --- a/src/model/channel/private_channel.rs +++ b/src/model/channel/private_channel.rs @@ -134,8 +134,8 @@ impl PrivateChannel { /// /// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html #[inline] - pub fn get_message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message> { - self.id.get_message(message_id) + pub fn message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message> { + self.id.message(message_id) } /// Gets messages from the channel. @@ -147,9 +147,9 @@ impl PrivateChannel { /// [`Channel::get_messages`]: enum.Channel.html#method.get_messages /// [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.id.get_messages(f) + self.id.messages(f) } /// Gets the list of [`User`]s who have reacted to a [`Message`] with a @@ -165,13 +165,13 @@ impl PrivateChannel { /// [`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>) + 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.id.get_reaction_users(message_id, reaction_type, limit, after) + self.id.reaction_users(message_id, reaction_type, limit, after) } /// Pins a [`Message`] to the channel. @@ -257,6 +257,39 @@ impl PrivateChannel { pub fn unpin<M: Into<MessageId>>(&self, message_id: M) -> Result<()> { self.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) + } } impl Display for PrivateChannel { |