From b098044a4b03463a6162efb4073a7ed42a3f3762 Mon Sep 17 00:00:00 2001 From: Visual Date: Mon, 30 Mar 2020 15:26:04 +0000 Subject: [PATCH] Fixed lazy role position updating due to not making sure that blacklisted id exists in state --- litecord/blueprints/guild/roles.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/litecord/blueprints/guild/roles.py b/litecord/blueprints/guild/roles.py index 1709756..ce39197 100644 --- a/litecord/blueprints/guild/roles.py +++ b/litecord/blueprints/guild/roles.py @@ -65,7 +65,7 @@ async def _role_update_dispatch(role_id: int, guild_id: int): """Dispatch a GUILD_ROLE_UPDATE with updated information on a role.""" role = await app.storage.get_role(role_id, guild_id) - await maybe_lazy_guild_dispatch(guild_id, "role_pos_upd", role) + await maybe_lazy_guild_dispatch(guild_id, "role_position_update", role) await app.dispatcher.guild.dispatch( guild_id, ("GUILD_ROLE_UPDATE", {"guild_id": str(guild_id), "role": role}) @@ -170,7 +170,8 @@ def gen_pairs( } for blacklisted_id in blacklist: - preferred_state.pop(blacklisted_id) + if blacklisted_id in preferred_state.keys(): + preferred_state.pop(blacklisted_id) # for each change, we must find a matching change # in the same list, so we can make a swap pair @@ -310,3 +311,4 @@ async def delete_guild_role(guild_id, role_id): ) return "", 204 +