diff options
| -rw-r--r-- | bot/cogs/off_topic_names.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/bot/cogs/off_topic_names.py b/bot/cogs/off_topic_names.py index 4dde9169f..0b0246667 100644 --- a/bot/cogs/off_topic_names.py +++ b/bot/cogs/off_topic_names.py @@ -48,8 +48,11 @@ async def update_names(bot: Bot, headers: dict): """ while True: + # To prevent the bot from sleeping until one second before midnight, we aim + # for one minute past midnight. This should prevent the ot-names cycling bug. + today_at_midnight = datetime.utcnow().replace(microsecond=0, second=0, minute=0, hour=0) - next_midnight = today_at_midnight + timedelta(days=1) + next_midnight = today_at_midnight + timedelta(days=1, minutes=1) seconds_to_sleep = (next_midnight - datetime.utcnow()).seconds await asyncio.sleep(seconds_to_sleep) |