async def handle_guild_role_update(self, gw: 'gateway.GatewayHandler', event_data: dict): """ Called when a role is updated. """ guild_id = int(event_data.get("guild_id", 0)) guild = self._guilds.get(guild_id) if not guild: return role_data = event_data.get("role") # type: dict if role_data is None: return role_id = int(role_data.get("id", 0)) if not role_id: return role = guild.roles.get(role_id) if not role: return old_role = role._copy() # Update all the fields on the role. event_data = event_data.get("role", {}) role.colour = event_data.get("color", 0) role.name = event_data.get("name") role.position = event_data.get("position") role.hoisted = event_data.get("hoisted") role.mentionable = event_data.get("mentionable") role.managed = event_data.get("managed") role.permissions = Permissions(event_data.get("permissions", 0)) yield "role_update", old_role, role,
def guild_permissions(self) -> Permissions: """ :return: The calculated guild permissions for a member. """ if self == self.guild.owner: return Permissions.all() bitfield = 0 # add the default roles bitfield |= self.guild.default_role.permissions.bitfield for role in self.roles: bitfield |= role.permissions.bitfield permissions = Permissions(bitfield) if permissions.administrator: return Permissions.all() return permissions