mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 12:18:59 +00:00
Add Member.top_role property to get the highest role.
This commit is contained in:
parent
07607060c1
commit
e19244b041
@ -150,3 +150,16 @@ class Member(User):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
return False
|
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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user