aboutsummaryrefslogtreecommitdiff
path: root/src/model
diff options
context:
space:
mode:
authorLakelezz <[email protected]>2018-05-29 18:11:06 +0200
committerAlex M. M <[email protected]>2018-05-29 18:11:06 +0200
commit1162e686592f23f4dc5ad509051858e453c82d1f (patch)
treee1d23880ef5339a2b9ee821b90855e6bcffa63d7 /src/model
parentdo not show the strikethrough-tip If no HelpBehaviour is `Strike` (#321) (diff)
downloadserenity-1162e686592f23f4dc5ad509051858e453c82d1f.tar.xz
serenity-1162e686592f23f4dc5ad509051858e453c82d1f.zip
Add methods to check whether `Message` is mentioning `User` (#323)
Diffstat (limited to 'src/model')
-rw-r--r--src/model/channel/message.rs15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs
index 978e181..f518987 100644
--- a/src/model/channel/message.rs
+++ b/src/model/channel/message.rs
@@ -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.