Skip to content

Commit

Permalink
[Gatekeep] Fixed bug with daily watch list check
Browse files Browse the repository at this point in the history
Due to the way the watch list removed its own entries in the loop, it would skip every other ID in the list. This new fix addresses that issue.
  • Loading branch information
Tsunderarislime committed Feb 13, 2025
1 parent f35194f commit 3953df7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cogs/gatekeep/gatekeep.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,9 @@ async def listWatch(self, ctx: Context):
if member:
text = f"{member.name}#{member.discriminator} ({member.id})"
display.append(text)
else:
text = f"Unknown User ({id})"
display.append(text)

# Check if the display list is empty
if not display:
Expand Down Expand Up @@ -481,6 +484,7 @@ async def checkWatchlist(self):
current = datetime.now(timezone.utc)
for guild in guilds:
watchList = await self.config.guild(guild).get_attr(KEY_WATCH_LIST)()
wl = await self.config.guild(guild).get_attr(KEY_WATCH_LIST)()
nDays = await self.config.guild(guild).get_attr(KEY_NEW_USER_DAYS)()
for id in watchList:
member = discord.utils.get(guild.members, id=id)
Expand All @@ -491,7 +495,7 @@ async def checkWatchlist(self):
or member.guild_permissions.administrator
or await self.bot.is_automod_immune(member)
):
watchList.remove(int(id))
wl.remove(int(id))
self.logger.info(
"%s#%s (%s) removed from the watch list. (Trusted user)",
member.name,
Expand All @@ -500,12 +504,12 @@ async def checkWatchlist(self):
)
else:
# Remove member if they are no longer in the server (can't log because of it being an id)
watchList.remove(int(id))
wl.remove(int(id))
self.logger.info(
"Member with id (%s) removed from the watch list. (Not in server)", id
)

await self.config.guild(guild).get_attr(KEY_WATCH_LIST).set(watchList)
await self.config.guild(guild).get_attr(KEY_WATCH_LIST).set(wl)
self.logger.info("Refreshed the watch list for %s", guild.name)

# The async function that is triggered on new member join.
Expand Down

0 comments on commit 3953df7

Please sign in to comment.