diff options
Diffstat (limited to 'src/ext/cache')
| -rw-r--r-- | src/ext/cache/mod.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/ext/cache/mod.rs b/src/ext/cache/mod.rs index 39baaf0..83ff46f 100644 --- a/src/ext/cache/mod.rs +++ b/src/ext/cache/mod.rs @@ -411,6 +411,20 @@ impl Cache { }) } + /// Retrieves a reference to a `User` based on appearance in + /// the first server they are in. + pub fn get_user<U>(&self, user_id: U) -> Option<&User> + where U: Into<UserId> + Clone { + for v in self.guilds.values() { + match v.members.get(&user_id.clone().into()) { + Some(x) => { return Some(&x.user) } + None => {} + } + } + + None + } + /// Retrieves a reference to a [`Guild`]'s role by their Ids. /// /// [`Guild`]: ../../model/struct.Guild.html |