diff options
| author | 2024-04-01 14:48:40 +0100 | |
|---|---|---|
| committer | 2024-04-01 14:48:40 +0100 | |
| commit | cfe3ec763d340a9c5b5a13087e47e209927edaf8 (patch) | |
| tree | d97e056cc1277e23e7b78f6b3f0a9d13da4dd741 | |
| parent | Correct type hint in the syncer cog. (diff) | |
| parent | Use a d.py task for checking for necro help posts (diff) | |
Merge pull request #2994 from python-discord/use-tasks-over-scheduler
Use a d.py task for checking for necro help posts
Diffstat (limited to '')
| -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."""  |