diff options
| author | 2019-04-16 00:38:43 +0200 | |
|---|---|---|
| committer | 2019-04-16 00:38:43 +0200 | |
| commit | 0329bbc25eea075ca830e6755c0512c949df93dc (patch) | |
| tree | 509eb45a8740183111ae46690a3114fd6c9c97f3 | |
| parent | Merge pull request #348 from python-discord/bb-uncaught-exception-fix (diff) | |
| parent | Fixing 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.py | 4 |
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( |