aboutsummaryrefslogtreecommitdiff
path: root/src/client/context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/context.rs')
-rw-r--r--src/client/context.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/client/context.rs b/src/client/context.rs
index eb7246b..e646ec6 100644
--- a/src/client/context.rs
+++ b/src/client/context.rs
@@ -22,7 +22,7 @@ use ::internal::prelude::*;
use ::model::*;
use ::utils;
-#[cfg(feature = "cache")]
+#[cfg(feature="cache")]
use super::CACHE;
/// The context is a general utility struct provided on event dispatches, which
@@ -1077,6 +1077,15 @@ impl Context {
Ok(channels)
}
+ /// Gets information about the current user.
+ ///
+ /// Note this is shorthand for retrieving the current user through the
+ /// cache, and will perform a clone.
+ #[cfg(all(feature = "cache", feature = "methods"))]
+ pub fn get_current_user(&self) -> CurrentUser {
+ CACHE.read().unwrap().user.clone()
+ }
+
/// Gets an [`Guild`]'s emoji by Id.
///
/// Requires the [Manage Emojis] permission.