Start scheduler after syncing commands

This commit is contained in:
2025-07-04 23:39:26 +02:00
parent 480b36ad85
commit 993a8fd6d9

View File

@ -286,12 +286,6 @@ class RemindBotClient(discord.Client):
async def setup_hook(self) -> None:
"""Setup the bot."""
if not scheduler.running:
logger.info("Starting the scheduler...")
scheduler.start()
else:
logger.error("Scheduler is already running.")
scheduler.add_listener(my_listener, EVENT_JOB_MISSED | EVENT_JOB_ERROR)
jobs: list[Job] = scheduler.get_jobs()
if jobs:
@ -309,6 +303,12 @@ class RemindBotClient(discord.Client):
await self.tree.sync(guild=None)
if not scheduler.running:
logger.info("Starting the scheduler...")
scheduler.start()
else:
logger.error("Scheduler is already running.")
def format_job_for_ui(job: Job) -> str:
"""Format a single job for display in the UI.