diff options
| author | Rapptz <[email protected]> | 2016-06-18 01:37:45 -0400 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2016-06-18 01:37:45 -0400 |
| commit | e19244b041b8cdecf31697c1a1fde4e4dca0e438 (patch) | |
| tree | e1f34d7f91e94caf9d02f5b99f8e64c3f36b0cf5 | |
| parent | Fix Colour.__str__ to actually pad zeroes. (diff) | |
| download | discord.py-e19244b041b8cdecf31697c1a1fde4e4dca0e438.tar.xz discord.py-e19244b041b8cdecf31697c1a1fde4e4dca0e438.zip | |
Add Member.top_role property to get the highest role.
| -rw-r--r-- | discord/member.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/discord/member.py b/discord/member.py index 23763728..20d829e3 100644 --- a/discord/member.py +++ b/discord/member.py @@ -150,3 +150,16 @@ class Member(User): return True return False + + @property + def top_role(self): + """Returns the member's highest role. + + This is useful for figuring where a member stands in the role + hierarchy chain. + """ + + if self.roles: + roles = sorted(self.roles, key=lambda r: r.position, reverse=True) + return roles[0] + return None |