diff options
author | 2024-03-16 06:52:46 +0000 | |
---|---|---|
committer | 2024-03-26 12:24:43 +0000 | |
commit | 5140378c3830f78709efed79d2676109b0ac3488 (patch) | |
tree | c9e5b5fdf3267406dbeff221f040596b89cfee75 | |
parent | Always cancel scheduled help post closes if present in scheduler when resched... (diff) |
Check every 5 minutes for idle help channels
This is to cover the case where a Discord outage causes us to miss a help post creation.
I purposefully didn't use the discord.py task system here as this cog already has it's own scheduler and deals with closing all active tasks itself
-rw-r--r-- | bot/exts/help_channels/_cog.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py index 2e7735148..c70ce4e71 100644 --- a/bot/exts/help_channels/_cog.py +++ b/bot/exts/help_channels/_cog.py @@ -38,9 +38,18 @@ class HelpForum(commands.Cog): self.help_forum_channel = self.bot.get_channel(constants.Channels.python_help) if not isinstance(self.help_forum_channel, discord.ForumChannel): raise TypeError("Channels.python_help is not a forum channel!") + await self.check_all_open_posts_have_close_task() + async def check_all_open_posts_have_close_task(self, delay: int = 5*60) -> None: + """ + Check that each open help post has a scheduled task to close, adding one if not. + + Once complete, schedule another check after `delay` seconds. + """ for post in self.help_forum_channel.threads: - await _channel.maybe_archive_idle_post(post, self.scheduler, has_task=False) + if post.id not in self.scheduler: + await _channel.maybe_archive_idle_post(post, self.scheduler) + self.scheduler.schedule_later(delay, "help_channel_idle_check", self.check_all_open_posts_have_close_task()) 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.""" |