aboutsummaryrefslogtreecommitdiffstats
path: root/bot/seasons/season.py
diff options
context:
space:
mode:
authorGravatar Shirayuki Nekomata <[email protected]>2020-03-05 00:11:17 +0700
committerGravatar GitHub <[email protected]>2020-03-05 00:11:17 +0700
commit20a47defed8169eb72f8dda5d889ada718155fd9 (patch)
treed9eebac255aebf138aff4044c78e9e7ebfcc8d7a /bot/seasons/season.py
parent(Games Cog): Added space between game search result + removed cutoff in get_c... (diff)
parentMerge pull request #366 from python-discord/tidy-seasonal-channels (diff)
Merge branch 'master' into games-command
Diffstat (limited to 'bot/seasons/season.py')
-rw-r--r--bot/seasons/season.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/bot/seasons/season.py b/bot/seasons/season.py
index e7b7a69c..763a08d2 100644
--- a/bot/seasons/season.py
+++ b/bot/seasons/season.py
@@ -383,18 +383,29 @@ class SeasonManager(commands.Cog):
"""Asynchronous timer loop to check for a new season every midnight."""
await self.bot.wait_until_ready()
await self.season.load()
+ days_since_icon_change = 0
while True:
await asyncio.sleep(self.sleep_time) # Sleep until midnight
- self.sleep_time = 86400 # Next time, sleep for 24 hours.
+ self.sleep_time = 24 * 3600 # Next time, sleep for 24 hours
+
+ days_since_icon_change += 1
+ log.debug(f"Days since last icon change: {days_since_icon_change}")
# If the season has changed, load it.
new_season = get_season(date=datetime.datetime.utcnow())
if new_season.name != self.season.name:
self.season = new_season
await self.season.load()
+ days_since_icon_change = 0 # Start counting afresh for the new season
+
+ # Otherwise we check whether it's time for an icon cycle within the current season
else:
- await self.season.change_server_icon()
+ if days_since_icon_change == Client.icon_cycle_frequency:
+ await self.season.change_server_icon()
+ days_since_icon_change = 0
+ else:
+ log.debug(f"Waiting {Client.icon_cycle_frequency - days_since_icon_change} more days to cycle icon")
@with_role(Roles.moderator, Roles.admin, Roles.owner)
@commands.command(name="season")