aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2020-12-01 22:28:16 +0100
committerGravatar Sebastiaan Zeeff <[email protected]>2020-12-01 22:28:16 +0100
commit575fedc0b4b22c712c541f7b49311ce2d02e9880 (patch)
treec112f5effacc1fa009595af2df91b218adb124ae
parentLet status update task sleep until the AoC starts (diff)
Ensure status countdown waits for bot start-up
Trying to change the rich presence status of the bot too early in the bot's start-up sequence will cause the task to fail. To make it wait, I've added a `bot.wait_until_guild_available` point before the main loop of the task starts. This seems to solve the issue reliably, despite the `guild_available` event not being directly related to when the bot's connection with the API is ready to accept presence updates. However, the `ready` event is know to fire too early, according to the discord.py community.
-rw-r--r--bot/exts/christmas/advent_of_code/_helpers.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/bot/exts/christmas/advent_of_code/_helpers.py b/bot/exts/christmas/advent_of_code/_helpers.py
index 57ad001a..9ba4d9be 100644
--- a/bot/exts/christmas/advent_of_code/_helpers.py
+++ b/bot/exts/christmas/advent_of_code/_helpers.py
@@ -411,6 +411,10 @@ async def countdown_status(bot: Bot) -> None:
# Log that we're going to start with the countdown status.
log.info("The Advent of Code has started or will start soon, starting countdown status.")
+ # Trying to change status too early in the bot's startup sequence will fail
+ # the task. Waiting until this event seems to work well.
+ await bot.wait_until_guild_available()
+
# Calculate when the task needs to stop running. To prevent the task from
# sleeping for the entire year, it will only wait in the currently
# configured year. This means that the task will only start hibernating once