diff options
| author | Illia <[email protected]> | 2016-12-07 20:09:04 +0200 |
|---|---|---|
| committer | zeyla <[email protected]> | 2016-12-07 10:09:04 -0800 |
| commit | 626ffb25af35f5b91a76fdccf6788382a1c39455 (patch) | |
| tree | da45ae770e06e68ea12910367a46b2d11aa90987 /src/ext/cache | |
| parent | Improve Mentions, fix MessageBuilder (diff) | |
| download | serenity-626ffb25af35f5b91a76fdccf6788382a1c39455.tar.xz serenity-626ffb25af35f5b91a76fdccf6788382a1c39455.zip | |
Allow mentionable structs to be used as command arguments
Add EmojiIdentifier, allow User, UserId, Role, RoleId, EmojiIdentifier,
Channel and ChannelId to be used as arguments for commands and add more
parsing functions to utils
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 |