|
|
@ -432,27 +432,11 @@ class Guild(Hashable): |
|
|
|
return member, before, after |
|
|
|
|
|
|
|
def _add_role(self, role: Role, /) -> None: |
|
|
|
# roles get added to the bottom (position 1, pos 0 is @everyone) |
|
|
|
# so since self.roles has the @everyone role, we can't increment |
|
|
|
# its position because it's stuck at position 0. Luckily x += False |
|
|
|
# is equivalent to adding 0. So we cast the position to a bool and |
|
|
|
# increment it. |
|
|
|
for r in self._roles.values(): |
|
|
|
r.position += not r.is_default() |
|
|
|
|
|
|
|
self._roles[role.id] = role |
|
|
|
|
|
|
|
def _remove_role(self, role_id: int, /) -> Role: |
|
|
|
# this raises KeyError if it fails.. |
|
|
|
role = self._roles.pop(role_id) |
|
|
|
|
|
|
|
# since it didn't, we can change the positions now |
|
|
|
# basically the same as above except we only decrement |
|
|
|
# the position if we're above the role we deleted. |
|
|
|
for r in self._roles.values(): |
|
|
|
r.position -= r.position > role.position |
|
|
|
|
|
|
|
return role |
|
|
|
return self._roles.pop(role_id) |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def _create_unavailable(cls, *, state: ConnectionState, guild_id: int, data: Optional[Dict[str, Any]]) -> Guild: |
|
|
|