aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Sebastiaan Zeeff <[email protected]>2019-04-16 00:38:43 +0200
committerGravatar GitHub <[email protected]>2019-04-16 00:38:43 +0200
commit0329bbc25eea075ca830e6755c0512c949df93dc (patch)
tree509eb45a8740183111ae46690a3114fd6c9c97f3
parentMerge pull request #348 from python-discord/bb-uncaught-exception-fix (diff)
parentFixing the off-by-one-second bug by adding additional second to sleep time (diff)
Merge pull request #352 from python-discord/fix-otnames-cycling-bug
Preventing multiple, rapid channel edits to change the ot-names.
-rw-r--r--bot/cogs/off_topic_names.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/bot/cogs/off_topic_names.py b/bot/cogs/off_topic_names.py
index 4dde9169f..58a53118e 100644
--- a/bot/cogs/off_topic_names.py
+++ b/bot/cogs/off_topic_names.py
@@ -48,9 +48,11 @@ async def update_names(bot: Bot, headers: dict):
"""
while True:
+ # Since we truncate the compute timedelta to seconds, we add one second to ensure
+ # we go past midnight in the `seconds_to_sleep` set below.
today_at_midnight = datetime.utcnow().replace(microsecond=0, second=0, minute=0, hour=0)
next_midnight = today_at_midnight + timedelta(days=1)
- seconds_to_sleep = (next_midnight - datetime.utcnow()).seconds
+ seconds_to_sleep = (next_midnight - datetime.utcnow()).seconds + 1
await asyncio.sleep(seconds_to_sleep)
response = await bot.http_session.get(