Better detection for the @everyone role.

This commit is contained in:
Rapptz 2015-10-17 04:13:15 -04:00
parent ba978cc988
commit a9fd4fc4e3
2 changed files with 8 additions and 3 deletions

View File

@ -197,7 +197,8 @@ class Role(object):
A boolean representing if the role will be displayed separately from other members. A boolean representing if the role will be displayed separately from other members.
.. attribute:: position .. attribute:: position
The position of the role. The position of the role. This number is usually positive. A non-positive value indicates that
this is the `@everyone` role.
.. attribute:: managed .. attribute:: managed
A boolean indicating if the role is managed by the server through some form of integration A boolean indicating if the role is managed by the server through some form of integration
@ -211,8 +212,12 @@ class Role(object):
self.id = kwargs.get('id') self.id = kwargs.get('id')
self.name = kwargs.get('name') self.name = kwargs.get('name')
self.permissions = Permissions(kwargs.get('permissions', 0)) self.permissions = Permissions(kwargs.get('permissions', 0))
self.position = kwargs.get('position', -1) self.position = kwargs.get('position', 0)
self.colour = Colour(kwargs.get('color', 0)) self.colour = Colour(kwargs.get('color', 0))
self.hoist = kwargs.get('hoist', False) self.hoist = kwargs.get('hoist', False)
self.managed = kwargs.get('managed', False) self.managed = kwargs.get('managed', False)
self.color = self.colour self.color = self.colour
def is_everyone(self):
"""Checks if the role is the @everyone role."""
return self.position == -1

View File

@ -151,5 +151,5 @@ class Server(object):
def get_default_role(self): def get_default_role(self):
"""Gets the @everyone role that all members have by default.""" """Gets the @everyone role that all members have by default."""
for role in self.roles: for role in self.roles:
if role.name == '@everyone': if role.is_everyone():
return role return role