From 5abf02b533a7318a9dc04754bb9e9fa6f8f16d5a Mon Sep 17 00:00:00 2001 From: Toby Jones Date: Fri, 20 Oct 2023 14:08:24 +0100 Subject: [PATCH] - Fixes an issue where the scheduled job can't run due to the bot reference being missing --- harmony_cogs/verify.py | 2 +- harmony_scheduled/verify.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/harmony_cogs/verify.py b/harmony_cogs/verify.py index ae58c82..48d358a 100644 --- a/harmony_cogs/verify.py +++ b/harmony_cogs/verify.py @@ -38,7 +38,7 @@ def __init__(self, bot: commands.Bot) -> None: self.bot.tree.add_command(whois_context_menu) self.bot.tree.add_command(update_role_context_menu) - check_reddit_accounts_task.start() + check_reddit_accounts_task.start(self.bot) def cog_unload(self) -> None: check_reddit_accounts_task.cancel() diff --git a/harmony_scheduled/verify.py b/harmony_scheduled/verify.py index ce3976d..a521086 100644 --- a/harmony_scheduled/verify.py +++ b/harmony_scheduled/verify.py @@ -5,7 +5,7 @@ import harmony_ui.verify from loguru import logger -from discord.ext import tasks +from discord.ext import tasks, commands from harmony_services import db as harmony_db from harmony_services import reddit as harmony_reddit @@ -18,7 +18,7 @@ @tasks.loop(seconds=config["schedule"]["reddit_account_check_interval_seconds"]) -async def check_reddit_accounts_task(): +async def check_reddit_accounts_task(bot: commands.Bot): """ Check Reddit accounts to make sure they haven't been banned from the subreddit, or deleted their account. :return: Nothing. @@ -35,7 +35,7 @@ async def check_reddit_accounts_task(): bans_fetch_limit: int = config["schedule"]["reddit_account_check_ban_fetch_limit"] try: - guild = await self.bot.fetch_guild(int(config["discord"]["guild_id"])) + guild = await bot.fetch_guild(int(config["discord"]["guild_id"])) if not guild: raise Exception(f"Failed to fetch the guild with ID {config['discord']['guild_id']}.")