diff options
| author | Zeyla Hellyer <[email protected]> | 2017-11-18 20:17:10 -0800 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-11-18 20:17:10 -0800 |
| commit | 82b87f196425ff8553bc9dcb84ddac9764b971e4 (patch) | |
| tree | b14c67494309a6d87c4ff217d07d0c8fbebd1d5f /src/model | |
| parent | Add `model::Reaction::channel` (diff) | |
| download | serenity-82b87f196425ff8553bc9dcb84ddac9764b971e4.tar.xz serenity-82b87f196425ff8553bc9dcb84ddac9764b971e4.zip | |
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.
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/channel/reaction.rs | 16 |
1 files changed, 13 insertions, 3 deletions
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<User> { + self.user_id.get() + } + /// Retrieves the list of [`User`]s who have reacted to a [`Message`] with a /// certain [`Emoji`]. /// |