From a9fd4fc4e358109510ce5be7302d7ce279bb3829 Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 17 Oct 2015 04:13:15 -0400 Subject: [PATCH] Better detection for the @everyone role. --- discord/role.py | 9 +++++++-- discord/server.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/discord/role.py b/discord/role.py index ce0b510a0..2fecfdf91 100644 --- a/discord/role.py +++ b/discord/role.py @@ -197,7 +197,8 @@ class Role(object): A boolean representing if the role will be displayed separately from other members. .. 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 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.name = kwargs.get('name') 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.hoist = kwargs.get('hoist', False) self.managed = kwargs.get('managed', False) self.color = self.colour + + def is_everyone(self): + """Checks if the role is the @everyone role.""" + return self.position == -1 diff --git a/discord/server.py b/discord/server.py index a50f0898e..1df6fd9c7 100644 --- a/discord/server.py +++ b/discord/server.py @@ -151,5 +151,5 @@ class Server(object): def get_default_role(self): """Gets the @everyone role that all members have by default.""" for role in self.roles: - if role.name == '@everyone': + if role.is_everyone(): return role