Skip to content

Commit

Permalink
Add mentions_current_user helper (#911)
Browse files Browse the repository at this point in the history
  • Loading branch information
mysteriouspants authored Jul 13, 2020
1 parent 4227a52 commit e049bc1
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/model/channel/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,19 @@ impl Message {
self.mentions_user_id(user.id)
}

/// Checks whether the message mentions the current user.
pub fn mentions_me(&self, cache_http: impl CacheHttp) -> Result<bool> {
#[cfg(feature = "cache")]
{
if let Some(cache) = cache_http.cache() {
return Ok(self.mentions_user_id(cache.read().user.id));
}
}

let current_user = cache_http.http().get_current_user()?;
Ok(self.mentions_user_id(current_user.id))
}

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

0 comments on commit e049bc1

Please sign in to comment.