aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authoracdenisSK <[email protected]>2017-07-09 02:13:14 +0200
committeracdenisSK <[email protected]>2017-07-09 02:13:14 +0200
commita7a09455e9646cbdaa4562058aef3c72178fc391 (patch)
treedc45a4c6e65724ce8beb51b893f47b7115a04594 /src
parentRemove the note from the comment on `reason` (diff)
downloadserenity-a7a09455e9646cbdaa4562058aef3c72178fc391.tar.xz
serenity-a7a09455e9646cbdaa4562058aef3c72178fc391.zip
Add a way to return all online members in a guild
Diffstat (limited to 'src')
-rw-r--r--src/model/guild/mod.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/model/guild/mod.rs b/src/model/guild/mod.rs
index 8270c94..03aa07e 100644
--- a/src/model/guild/mod.rs
+++ b/src/model/guild/mod.rs
@@ -668,6 +668,24 @@ impl Guild {
self.id.members(limit, after)
}
+ /// Gets a list of all the online members in this guild.
+ pub fn online_members(&self) -> Vec<&Member> {
+ let mut members = vec![];
+
+ for (&id, ref member) in &self.members {
+ match self.presences.get(&id) {
+ Some(ref presence) => {
+ if OnlineStatus::Online == presence.status {
+ members.push(*member);
+ }
+ },
+ None => continue,
+ }
+ }
+
+ members
+ }
+
/// Retrieves the first [`Member`] found that matches the name - with an
/// optional discriminator - provided.
///