mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-09-05 17:36:15 +00:00
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.
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user