aboutsummaryrefslogtreecommitdiff
path: root/discord/role.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2018-09-24 21:05:41 -0400
committerRapptz <[email protected]>2018-09-24 21:08:48 -0400
commit3d03dbc45179f645b59838729047e896cc387049 (patch)
tree63592f4d631c33ee0b22b7f6bb57818ad48b2671 /discord/role.py
parentTake the default role property into account when comparing roles. (diff)
downloaddiscord.py-3d03dbc45179f645b59838729047e896cc387049.tar.xz
discord.py-3d03dbc45179f645b59838729047e896cc387049.zip
Change internal role storage in Guild to a dict instead of a list.
This adds the following APIs: * Guild.get_role This removes the following APIs: * Guild.role_hierarchy To compensate for the removed APIs, Guild.roles is now a sorted list based on hierarchy. The first element will always be the @everyone role. This speeds up access at the cost of some memory, theoretically.
Diffstat (limited to 'discord/role.py')
-rw-r--r--discord/role.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/discord/role.py b/discord/role.py
index 086d5e55..4610c7d0 100644
--- a/discord/role.py
+++ b/discord/role.py
@@ -188,10 +188,7 @@ class Role(Hashable):
http = self._state.http
change_range = range(min(self.position, position), max(self.position, position) + 1)
- sorted_roles = sorted((x for x in self.guild.roles if x.position in change_range and x.id != self.id),
- key=lambda x: x.position)
-
- roles = [r.id for r in sorted_roles]
+ roles = [r.id for r in self.guild.roles[1:] if x.position in change_range]
if self.position > position:
roles.insert(0, self.id)