From 82b87f196425ff8553bc9dcb84ddac9764b971e4 Mon Sep 17 00:00:00 2001 From: Zeyla Hellyer Date: Sat, 18 Nov 2017 20:17:10 -0800 Subject: Add `model::Reaction::user` Add a `user` method to `Reaction::user`, which retrieves the User who made the reaction. This will check the cache for the user and, if either disabled or not found, falls back to hitting the REST API. --- src/model/channel/reaction.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/model/channel/reaction.rs b/src/model/channel/reaction.rs index 8fe8dc1..b2fdffd 100644 --- a/src/model/channel/reaction.rs +++ b/src/model/channel/reaction.rs @@ -34,9 +34,9 @@ pub struct Reaction { impl Reaction { /// Retrieves the associated the reaction was made in. /// - /// If the cache is enabled, this will search for the alread-cached channel. - /// If not - or the channel was not found - this will perform a request over - /// the REST API for the channel. + /// If the cache is enabled, this will search for the already-cached + /// channel. If not - or the channel was not found - this will perform a + /// request over the REST API for the channel. /// /// Requires the [Read Message History] permission. /// @@ -108,6 +108,16 @@ impl Reaction { self.channel_id.message(self.message_id) } + /// Retrieves the user that made the reaction. + /// + /// If the cache is enabled, this will search for the already-cached user. + /// If not - or the user was not found - this will perform a request over + /// the REST API for the user. + #[inline] + pub fn user(&self) -> Result { + self.user_id.get() + } + /// Retrieves the list of [`User`]s who have reacted to a [`Message`] with a /// certain [`Emoji`]. /// -- cgit v1.2.3