diff options
| author | 2022-02-18 17:13:31 +0000 | |
|---|---|---|
| committer | 2022-02-18 17:13:55 +0000 | |
| commit | 3346d71416fdb3223d0c4998f92e420886445fac (patch) | |
| tree | ddb70f3aa166502802e0dcbf621777d691db503d | |
| parent | Add logic so that manually archived threads bypass the thread bump list (diff) | |
fixup: implemeent code review comments
Diffstat (limited to '')
| -rw-r--r-- | bot/exts/utils/thread_bumper.py | 11 | 
1 files changed, 8 insertions, 3 deletions
| diff --git a/bot/exts/utils/thread_bumper.py b/bot/exts/utils/thread_bumper.py index 8c6f3518e..35057f1fe 100644 --- a/bot/exts/utils/thread_bumper.py +++ b/bot/exts/utils/thread_bumper.py @@ -74,7 +74,7 @@ class ThreadBumper(commands.Cog):          if not ctx.invoked_subcommand:              await ctx.send_help(ctx.command) -    @thread_bump_group.command(name="add") +    @thread_bump_group.command(name="add", aliases=("a",))      async def add_thread_to_bump_list(self, ctx: commands.Context, thread: t.Optional[discord.Thread]) -> None:          """Add a thread to the bump list."""          await self.init_task @@ -85,6 +85,9 @@ class ThreadBumper(commands.Cog):              else:                  raise commands.BadArgument("You must provide a thread, or run this command within a thread.") +        if await self.threads_to_bump.contains(thread.id): +            raise commands.BadArgument("This thread is already in the bump list.") +          await self.threads_to_bump.set(thread.id, "sentinel")          await ctx.send(f":ok_hand:{thread.mention} has been added to the bump list.") @@ -99,6 +102,9 @@ class ThreadBumper(commands.Cog):              else:                  raise commands.BadArgument("You must provide a thread, or run this command within a thread.") +        if not await self.threads_to_bump.contains(thread.id): +            raise commands.BadArgument("This thread is not in the bump list.") +          await self.threads_to_bump.delete(thread.id)          await ctx.send(f":ok_hand: {thread.mention} has been removed from the bump list.") @@ -126,8 +132,7 @@ class ThreadBumper(commands.Cog):          if not after.archived:              return -        bumped_threads = [k for k, _ in await self.threads_to_bump.items()] -        if after.id in bumped_threads: +        if await self.threads_to_bump.contains(after.id):              await self.unarchive_threads_not_manually_archived([after])      async def cog_check(self, ctx: commands.Context) -> bool: | 
