Add Member.top_role property to get the highest role.

This commit is contained in:
Rapptz 2016-06-18 01:37:45 -04:00
parent 07607060c1
commit e19244b041

View File

@ -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