Browse Source

Better detection for the @everyone role.

pull/24/head
Rapptz 10 years ago
parent
commit
a9fd4fc4e3
  1. 9
      discord/role.py
  2. 2
      discord/server.py

9
discord/role.py

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

2
discord/server.py

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

Loading…
Cancel
Save