diff options
author | 2025-02-07 16:43:30 +0000 | |
---|---|---|
committer | 2025-02-07 16:43:30 +0000 | |
commit | d1268952b5afba893790c45ce02c90b2acc95b81 (patch) | |
tree | 0e041db676d898baa32c40849b3815b6dfcf7721 | |
parent | Fetch latest help post further up the call stack when looking to archive (diff) |
Only pass post_id to the scheulded task, to be clear on intentions
-rw-r--r-- | bot/exts/help_channels/_channel.py | 6 | ||||
-rw-r--r-- | bot/exts/help_channels/_cog.py | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index 43b9a858d..4e65d9379 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -189,11 +189,11 @@ async def get_closing_time(post: discord.Thread) -> tuple[arrow.Arrow, _stats.Cl return time, _stats.ClosingReason.INACTIVE -async def maybe_archive_idle_post(post: discord.Thread, scheduler: scheduling.Scheduler) -> None: +async def maybe_archive_idle_post(post_id: int, scheduler: scheduling.Scheduler) -> None: """Archive the `post` if idle, or schedule the archive for later if still active.""" try: # Fetch the post again, to ensure we have the latest info - post = await get_or_fetch_channel(bot.instance, post.id) + post = await get_or_fetch_channel(bot.instance, post_id) except discord.HTTPException: log.trace(f"Not closing missing post #{post} ({post.id}).") return @@ -221,4 +221,4 @@ async def maybe_archive_idle_post(post: discord.Thread, scheduler: scheduling.Sc delay = (closing_time - arrow.utcnow()).seconds log.info(f"#{post} ({post.id}) is still active; scheduling it to be archived after {delay} seconds.") - scheduler.schedule_later(delay, post.id, maybe_archive_idle_post(post, scheduler)) + scheduler.schedule_later(delay, post.id, maybe_archive_idle_post(post.id, scheduler)) diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py index 9db66bb39..5e0b1799f 100644 --- a/bot/exts/help_channels/_cog.py +++ b/bot/exts/help_channels/_cog.py @@ -47,7 +47,7 @@ class HelpForum(commands.Cog): """Check that each open help post has a scheduled task to close, adding one if not.""" for post in self.help_forum_channel.threads: if post.id not in self.scheduler: - await _channel.maybe_archive_idle_post(post, self.scheduler) + await _channel.maybe_archive_idle_post(post.id, self.scheduler) async def close_check(self, ctx: commands.Context) -> bool: """Return True if the channel is a help post, and the user is the claimant or has a whitelisted role.""" @@ -116,7 +116,7 @@ class HelpForum(commands.Cog): self.scheduler.schedule_later( delay, thread.id, - _channel.maybe_archive_idle_post(thread, self.scheduler) + _channel.maybe_archive_idle_post(thread.id, self.scheduler) ) @commands.Cog.listener() |