diff options
| -rw-r--r-- | src/model/channel/message.rs | 15 |
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. |