diff options
| author | acdenisSK <[email protected]> | 2017-10-03 16:55:58 +0200 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-10-09 15:47:48 -0700 |
| commit | 06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a (patch) | |
| tree | eee16dc9d1c35e2b17a0a59d55cc85fa82726587 /src/model/channel/channel_id.rs | |
| parent | Use the de-generification trick. (diff) | |
| download | serenity-06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a.tar.xz serenity-06dc6937bd3d4e5912de08e4ac3630a1f83b7f5a.zip | |
Revert "Use the de-generification trick."
Makes the compiliation time just a bit worse
Diffstat (limited to 'src/model/channel/channel_id.rs')
| -rw-r--r-- | src/model/channel/channel_id.rs | 61 |
1 files changed, 10 insertions, 51 deletions
diff --git a/src/model/channel/channel_id.rs b/src/model/channel/channel_id.rs index 04ed266..4cc997d 100644 --- a/src/model/channel/channel_id.rs +++ b/src/model/channel/channel_id.rs @@ -81,11 +81,7 @@ impl ChannelId { #[inline] pub fn create_reaction<M, R>(&self, message_id: M, reaction_type: R) -> Result<()> where M: Into<MessageId>, R: Into<ReactionType> { - self._create_reaction(message_id.into(), reaction_type.into()) - } - - fn _create_reaction(&self, MessageId(id): MessageId, reaction_type: ReactionType) -> Result<()> { - http::create_reaction(self.0, id, &reaction_type) + http::create_reaction(self.0, message_id.into().0, &reaction_type.into()) } /// Deletes this channel, returning the channel on a successful deletion. @@ -104,11 +100,7 @@ impl ChannelId { /// [Manage Messages]: permissions/constant.MANAGE_MESSAGES.html #[inline] pub fn delete_message<M: Into<MessageId>>(&self, message_id: M) -> Result<()> { - self._delete_message(message_id.into()) - } - - fn _delete_message(&self, MessageId(id): MessageId) -> Result<()> { - http::delete_message(self.0, id) + http::delete_message(self.0, message_id.into().0) } /// Deletes all messages by Ids from the given vector in the given channel. @@ -164,18 +156,11 @@ impl ChannelId { reaction_type: R) -> Result<()> where M: Into<MessageId>, R: Into<ReactionType> { - self._delete_reaction(message_id.into(), user_id, reaction_type.into()) - } - - fn _delete_reaction(&self, - MessageId(id): MessageId, - user_id: Option<UserId>, - reaction_type: ReactionType) -> Result<()> { http::delete_reaction( self.0, - id, + message_id.into().0, user_id.map(|uid| uid.0), - &reaction_type, + &reaction_type.into(), ) } @@ -224,11 +209,6 @@ impl ChannelId { /// [`the limit`]: ../builder/struct.CreateMessage.html#method.content pub fn edit_message<F, M>(&self, message_id: M, f: F) -> Result<Message> where F: FnOnce(CreateMessage) -> CreateMessage, M: Into<MessageId> { - self._edit_message(message_id.into(), f) - } - - fn _edit_message<F>(&self, MessageId(id): MessageId, f: F) -> Result<Message> - where F: FnOnce(CreateMessage) -> CreateMessage { let map = f(CreateMessage::default()).0; if let Some(content) = map.get("content") { @@ -239,7 +219,7 @@ impl ChannelId { } } - http::edit_message(self.0, id, &Value::Object(map)) + http::edit_message(self.0, message_id.into().0, &Value::Object(map)) } /// Search the cache for the channel with the Id. @@ -273,11 +253,7 @@ impl ChannelId { /// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html #[inline] pub fn message<M: Into<MessageId>>(&self, message_id: M) -> Result<Message> { - self._message(message_id.into()) - } - - fn _message(&self, MessageId(id): MessageId) -> Result<Message> { - http::get_message(self.0, id) + http::get_message(self.0, message_id.into().0) .map(|mut msg| { msg.transform_content(); @@ -350,11 +326,7 @@ impl ChannelId { /// [`Message`]: struct.Message.html #[inline] pub fn pin<M: Into<MessageId>>(&self, message_id: M) -> Result<()> { - self._pin(message_id.into()) - } - - fn _pin(&self, MessageId(id): MessageId) -> Result<()> { - http::pin_message(self.0, id) + http::pin_message(self.0, message_id.into().0) } /// Gets the list of [`Message`]s which are pinned to the channel. @@ -382,23 +354,14 @@ impl ChannelId { after: Option<U>) -> Result<Vec<User>> where M: Into<MessageId>, R: Into<ReactionType>, U: Into<UserId> { - self._reaction_users(message_id.into(), reaction_type.into(), limit, after.map(|u| u.into())) - } - - fn _reaction_users(&self, - MessageId(id): MessageId, - reaction_type: ReactionType, - limit: Option<u8>, - after: Option<UserId>) - -> Result<Vec<User>> { let limit = limit.map_or(50, |x| if x > 100 { 100 } else { x }); http::get_reaction_users( self.0, - id, - &reaction_type, + message_id.into().0, + &reaction_type.into(), limit, - after.map(|u| u.0), + after.map(|u| u.into().0), ) } @@ -541,10 +504,6 @@ impl ChannelId { http::unpin_message(self.0, message_id.into().0) } - fn _unpin(&self, MessageId(id): MessageId) -> Result<()> { - http::unpin_message(self.0, id) - } - /// Retrieves the channel's webhooks. /// /// **Note**: Requires the [Manage Webhooks] permission. |