aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar SebastiaanZ <[email protected]>2019-04-15 07:16:26 +0200
committerGravatar SebastiaanZ <[email protected]>2019-04-15 07:16:26 +0200
commit7b4994a07ea9d3f42e796950856a017f887dabb8 (patch)
tree34c9852eaf004aa9d8bfa6b5cb934aa2c66a2c46
parentMerge pull request #348 from python-discord/bb-uncaught-exception-fix (diff)
Preventing the ot-names cycling bug by sleeping until one minute past midnight
-rw-r--r--bot/cogs/off_topic_names.py5
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)