aboutsummaryrefslogtreecommitdiff
path: root/src/model/channel
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2018-01-05 22:41:18 -0800
committerZeyla Hellyer <[email protected]>2018-01-05 22:41:18 -0800
commit85d7d5f6a6df9841659bc7ad8e392f31c1aae46c (patch)
tree001ea9d81f51f8919a5b07cbea9f64621955dd35 /src/model/channel
parentFix permission overwrites in permission building (diff)
downloadserenity-85d7d5f6a6df9841659bc7ad8e392f31c1aae46c.tar.xz
serenity-85d7d5f6a6df9841659bc7ad8e392f31c1aae46c.zip
Further generic-ify `reaction_users` `after` param
Further generic-ify the `after` parameter on the `reaction_users` method of the following structs: - `ChannelId` - `Group` - `GuildChannel` - `Message` - `Channel` - `GuildChannel` Do this by changing the `U` trait bound from `Into<UserId>` to `Into<Option<UserId>>`. This resolves problems determining types when passing `None` as the argument, as reported in #247.
Diffstat (limited to 'src/model/channel')
-rw-r--r--src/model/channel/channel_id.rs15
-rw-r--r--src/model/channel/group.rs19
-rw-r--r--src/model/channel/guild_channel.rs19
-rw-r--r--src/model/channel/message.rs16
-rw-r--r--src/model/channel/mod.rs16
-rw-r--r--src/model/channel/private_channel.rs16
6 files changed, 52 insertions, 49 deletions
diff --git a/src/model/channel/channel_id.rs b/src/model/channel/channel_id.rs
index 8ebdf2a..7093dfb 100644
--- a/src/model/channel/channel_id.rs
+++ b/src/model/channel/channel_id.rs
@@ -358,12 +358,13 @@ impl ChannelId {
/// [`User`]: struct.User.html
/// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html
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> {
+ message_id: M,
+ reaction_type: R,
+ limit: Option<u8>,
+ after: U,
+ ) -> Result<Vec<User>> where M: Into<MessageId>,
+ R: Into<ReactionType>,
+ U: Into<Option<UserId>> {
let limit = limit.map_or(50, |x| if x > 100 { 100 } else { x });
http::get_reaction_users(
@@ -371,7 +372,7 @@ impl ChannelId {
message_id.into().0,
&reaction_type.into(),
limit,
- after.map(|u| u.into().0),
+ after.into().map(|x| x.0),
)
}
diff --git a/src/model/channel/group.rs b/src/model/channel/group.rs
index 4a4070a..69e9cc7 100644
--- a/src/model/channel/group.rs
+++ b/src/model/channel/group.rs
@@ -238,15 +238,16 @@ impl Group {
/// [`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)
+ pub fn reaction_users<M, R, U>(
+ &self,
+ message_id: M,
+ reaction_type: R,
+ limit: Option<u8>,
+ after: U,
+ ) -> Result<Vec<User>> where M: Into<MessageId>,
+ R: Into<ReactionType>,
+ U: Into<Option<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
diff --git a/src/model/channel/guild_channel.rs b/src/model/channel/guild_channel.rs
index 4d729ea..3653cb6 100644
--- a/src/model/channel/guild_channel.rs
+++ b/src/model/channel/guild_channel.rs
@@ -531,15 +531,16 @@ impl GuildChannel {
/// [`Message`]: struct.Message.html
/// [`User`]: struct.User.html
/// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html
- 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
- .reaction_users(message_id, reaction_type, limit, after)
+ pub fn reaction_users<M, R, U>(
+ &self,
+ message_id: M,
+ reaction_type: R,
+ limit: Option<u8>,
+ after: U,
+ ) -> Result<Vec<User>> where M: Into<MessageId>,
+ R: Into<ReactionType>,
+ U: Into<Option<UserId>> {
+ self.id.reaction_users(message_id, reaction_type, limit, after)
}
/// Sends a message with just the given message content in the channel.
diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs
index 1bb55ab..f3834bd 100644
--- a/src/model/channel/message.rs
+++ b/src/model/channel/message.rs
@@ -313,14 +313,14 @@ impl Message {
/// [`User`]: struct.User.html
/// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html
#[inline]
- 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
- .reaction_users(self.id, reaction_type, limit, after)
+ pub fn reaction_users<R, U>(
+ &self,
+ reaction_type: R,
+ limit: Option<u8>,
+ after: U,
+ ) -> Result<Vec<User>> where R: Into<ReactionType>,
+ U: Into<Option<UserId>> {
+ self.channel_id.reaction_users(self.id, reaction_type, limit, after)
}
/// Returns the associated `Guild` for the message if one is in the cache.
diff --git a/src/model/channel/mod.rs b/src/model/channel/mod.rs
index 00fc7f6..1a6bcd5 100644
--- a/src/model/channel/mod.rs
+++ b/src/model/channel/mod.rs
@@ -371,14 +371,14 @@ impl Channel {
#[deprecated(since = "0.4.2", note = "Use the inner channel's method")]
#[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.id()
- .reaction_users(message_id, reaction_type, limit, after)
+ message_id: M,
+ reaction_type: R,
+ limit: Option<u8>,
+ after: U,
+ ) -> Result<Vec<User>> where M: Into<MessageId>,
+ R: Into<ReactionType>,
+ U: Into<Option<UserId>> {
+ self.id().reaction_users(message_id, reaction_type, limit, after)
}
/// Retrieves the Id of the inner [`Group`], [`GuildChannel`], or
diff --git a/src/model/channel/private_channel.rs b/src/model/channel/private_channel.rs
index 877fa13..39dcac3 100644
--- a/src/model/channel/private_channel.rs
+++ b/src/model/channel/private_channel.rs
@@ -189,14 +189,14 @@ impl PrivateChannel {
/// [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.id
- .reaction_users(message_id, reaction_type, limit, after)
+ message_id: M,
+ reaction_type: R,
+ limit: Option<u8>,
+ after: U,
+ ) -> Result<Vec<User>> where M: Into<MessageId>,
+ R: Into<ReactionType>,
+ U: Into<Option<UserId>> {
+ self.id.reaction_users(message_id, reaction_type, limit, after)
}
/// Pins a [`Message`] to the channel.