aboutsummaryrefslogtreecommitdiff
path: root/src/cache
diff options
context:
space:
mode:
authorMishio595 <[email protected]>2018-07-24 17:19:22 -0600
committerMishio595 <[email protected]>2018-07-24 17:19:22 -0600
commitcd3c3ececb24a7da4a4c99543cac5127f092a10a (patch)
treead20f6506579f47c64b8b5e06325cdd1c8f30f57 /src/cache
parentFallback to default-command if passed sub-command is wrong (diff)
downloadserenity-cd3c3ececb24a7da4a4c99543cac5127f092a10a.tar.xz
serenity-cd3c3ececb24a7da4a4c99543cac5127f092a10a.zip
EventHandler::message_update with cache feature sends old message if available
Diffstat (limited to 'src/cache')
-rw-r--r--src/cache/mod.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/cache/mod.rs b/src/cache/mod.rs
index 14e1a14..913fe21 100644
--- a/src/cache/mod.rs
+++ b/src/cache/mod.rs
@@ -578,6 +578,17 @@ impl Cache {
})
}
+ #[inline]
+ pub fn message<C, M>(&self, channel_id: C, user_id: M) -> Option<Message>
+ where C: Into<ChannelId>, M: Into<MessageId> {
+ self._message(channel_id.into(), user_id.into())
+ }
+
+ fn _message(&self, channel_id: ChannelId, message_id: MessageId) -> Option<Message> {
+ self.messages.get(&channel_id).and_then(|messages| {
+ messages.get(&message_id).cloned()
+ })
+ }
/// Retrieves a [`PrivateChannel`] from the cache's [`private_channels`]
/// map, if it exists.
///