diff options
-rw-r--r-- | bot/exts/help_channels/_cog.py | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/bot/exts/help_channels/_cog.py b/bot/exts/help_channels/_cog.py index 59a95ab6a..96c0a89ba 100644 --- a/bot/exts/help_channels/_cog.py +++ b/bot/exts/help_channels/_cog.py @@ -1,7 +1,7 @@ """Contains the Cog that receives discord.py events and defers most actions to other files in the module.""" import discord -from discord.ext import commands +from discord.ext import commands, tasks from pydis_core.utils import scheduling from bot import constants @@ -38,18 +38,14 @@ 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() + self.check_all_open_posts_have_close_task.start() - 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. - """ + @tasks.loop(minutes=5) + async def check_all_open_posts_have_close_task(self) -> None: + """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) - 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.""" |