diff options
| author | Zeyla Hellyer <[email protected]> | 2017-11-18 20:14:52 -0800 |
|---|---|---|
| committer | Zeyla Hellyer <[email protected]> | 2017-11-18 20:14:52 -0800 |
| commit | e02a842fb76b1e591287395ac223cc1c04913820 (patch) | |
| tree | 0311e19f0180a48660aeef704825647ab9897d19 /src/model | |
| parent | Alphabetize Reaction methods (diff) | |
| download | serenity-e02a842fb76b1e591287395ac223cc1c04913820.tar.xz serenity-e02a842fb76b1e591287395ac223cc1c04913820.zip | |
Add `model::Reaction::channel`
Adds a `channel` method to `model::Reaction`, which retrieves the
channel the reaction was made in from the Cache, falling back to hitting
the REST API if one was not found (or the cache is disabled).
Diffstat (limited to 'src/model')
| -rw-r--r-- | src/model/channel/reaction.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/model/channel/reaction.rs b/src/model/channel/reaction.rs index d814e4d..8fe8dc1 100644 --- a/src/model/channel/reaction.rs +++ b/src/model/channel/reaction.rs @@ -32,6 +32,20 @@ pub struct Reaction { #[cfg(feature = "model")] 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. + /// + /// Requires the [Read Message History] permission. + /// + /// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html + #[inline] + pub fn channel(&self) -> Result<Channel> { + self.channel_id.get() + } + /// Deletes the reaction, but only if the current user is the user who made /// the reaction or has permission to. /// @@ -89,6 +103,7 @@ impl Reaction { /// /// [Read Message History]: permissions/constant.READ_MESSAGE_HISTORY.html /// [`Message`]: struct.Message.html + #[inline] pub fn message(&self) -> Result<Message> { self.channel_id.message(self.message_id) } |