From 5a967241efabd49116a6d6d5a6eeb95d3281d93b Mon Sep 17 00:00:00 2001 From: acdenisSK Date: Wed, 26 Jul 2017 03:57:16 +0200 Subject: Add a util function for checking if a message was sent by the bot or someone else --- src/model/channel/message.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src') diff --git a/src/model/channel/message.rs b/src/model/channel/message.rs index 372c3de..3298305 100644 --- a/src/model/channel/message.rs +++ b/src/model/channel/message.rs @@ -115,6 +115,12 @@ impl Message { CACHE.read().unwrap().channel(self.channel_id) } + /// A util function for determining whether this message was sent by someone else, or the bot. + #[cfg(all(feature="cache", feature="utils"))] + pub fn is_current_user(&self) -> bool { + self.author.id == CACHE.read().unwrap().id + } + /// Deletes the message. /// /// **Note**: The logged in user must either be the author of the message or -- cgit v1.2.3