diff --git a/discord_reminder_bot/main.py b/discord_reminder_bot/main.py index 8965ac4..c85024f 100644 --- a/discord_reminder_bot/main.py +++ b/discord_reminder_bot/main.py @@ -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.