Skip to content

Commit

Permalink
Add methods to check whether Message is mentioning User (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lakelezz authored and arqunis committed May 29, 2018
1 parent 32c3bed commit 1162e68
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/model/channel/message.rs
Expand Up @@ -490,6 +490,21 @@ impl Message {
http::send_message(self.channel_id.0, &map)
}

/// Checks whether the message mentions passed [`UserId`].
///
/// [`UserId`]: ../../model/id/struct.UserId.html
pub fn mentions_user_id<I: Into<UserId>>(&self, id: I) -> bool {
let user_id_to_find = id.into();
self.mentions.iter().any(|mentioned_user| mentioned_user.id.0 == user_id_to_find.0)
}

/// Checks whether the message mentions passed [`User`].
///
/// [`User`]: ../user/struct.User.html
pub fn mentions_user(&self, user: &User) -> bool {
self.mentions_user_id(user.id)
}

/// Unpins the message from its channel.
///
/// **Note**: Requires the [Manage Messages] permission.
Expand Down

0 comments on commit 1162e68

Please sign in to comment.