diff options
author | 2024-07-18 23:04:28 +0200 | |
---|---|---|
committer | 2024-07-18 23:04:28 +0200 | |
commit | 25acba42f18b7f5ef813dd7ed5d62cead9f3940b (patch) | |
tree | 9152898777c2e5da224d8d19951cf5b4a0f0f48b | |
parent | Fix: dict.values() -> dict.items() (diff) |
Copy watched_users into list to prevent modification while iterating
-rw-r--r-- | bot/exts/moderation/watchchannels/_watchchannel.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bot/exts/moderation/watchchannels/_watchchannel.py b/bot/exts/moderation/watchchannels/_watchchannel.py index 768d0afb3..44c0be2a7 100644 --- a/bot/exts/moderation/watchchannels/_watchchannel.py +++ b/bot/exts/moderation/watchchannels/_watchchannel.py @@ -344,12 +344,13 @@ class WatchChannel(metaclass=CogABCMeta): update_cache = False list_data["updated"] = update_cache - watched_iter = self.watched_users.items() + # Copy into list to prevent issues if it is modified elsewhere while it's being iterated over. + watched_list = list(self.watched_users.items()) if oldest_first: - watched_iter = reversed(watched_iter) + watched_list.reverse() list_data["info"] = {} - for user_id, user_data in watched_iter: + for user_id, user_data in watched_list: member = await get_or_fetch_member(ctx.guild, user_id) line = f"- `{user_id}`" if member: |