Pull request #3: Fixed lazy role position updating due to not making sure that blacklisted id exists in state

Merge in LIT/litecord from bugfix/lazy-role-update to master

* commit '2629e2a725deb71764504d48760c51cb6f743a45':
  Fixed lazy role position updating due to not making sure that blacklisted id exists in state
This commit is contained in:
George Tsatsis 2020-03-30 15:31:43 +00:00
commit 8ccf6304a3
1 changed files with 4 additions and 2 deletions

View File

@ -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.""" """Dispatch a GUILD_ROLE_UPDATE with updated information on a role."""
role = await app.storage.get_role(role_id, guild_id) 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( await app.dispatcher.guild.dispatch(
guild_id, ("GUILD_ROLE_UPDATE", {"guild_id": str(guild_id), "role": role}) guild_id, ("GUILD_ROLE_UPDATE", {"guild_id": str(guild_id), "role": role})
@ -170,7 +170,8 @@ def gen_pairs(
} }
for blacklisted_id in blacklist: 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 # for each change, we must find a matching change
# in the same list, so we can make a swap pair # 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 return "", 204