aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeyla Hellyer <[email protected]>2017-10-24 07:52:24 -0700
committerZeyla Hellyer <[email protected]>2017-10-24 07:53:22 -0700
commitd3015a0ff0c0c87888437f991945453b92296875 (patch)
tree7b86b582de68960dadf70df14ecb88564c625527
parentAdd a debug impl for `DispatchError` (diff)
downloadserenity-d3015a0ff0c0c87888437f991945453b92296875.tar.xz
serenity-d3015a0ff0c0c87888437f991945453b92296875.zip
Fix User::has_role
Fix the return value of the function by properly checking whether the user has the role in the given guild. The function made the erraneous mistake of simply checking if the given guild had the role by Id, not whether the _member in the given guild_ had the role by Id.
-rw-r--r--src/model/user.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/model/user.rs b/src/model/user.rs
index c1c3135..3d39759 100644
--- a/src/model/user.rs
+++ b/src/model/user.rs
@@ -599,7 +599,11 @@ impl User {
.unwrap()
.guilds
.get(&_guild_id)
- .map(|g| g.read().unwrap().roles.contains_key(&role_id))
+ .map(|g| {
+ g.read().unwrap().members.get(&self.id)
+ .map(|m| m.roles.contains(&role_id))
+ .unwrap_or(false)
+ })
.unwrap_or(false)
} else {
true