Skip to content

Commit

Permalink
- Fixes an issue where the scheduled job can't run due to the bot ref…
Browse files Browse the repository at this point in the history
…erence being missing
  • Loading branch information
emberdex committed Oct 20, 2023
1 parent aff46a5 commit 5abf02b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion harmony_cogs/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions harmony_scheduled/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.
Expand All @@ -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']}.")
Expand Down

0 comments on commit 5abf02b

Please sign in to comment.