diff options
| author | 2020-02-25 09:02:42 -0600 | |
|---|---|---|
| committer | 2020-02-25 09:02:42 -0600 | |
| commit | 08e78bdaa481886de43d162570496b2b9596c02d (patch) | |
| tree | 7a23091700eba50711e1232f444368c4711ccd0f /bot/seasons/season.py | |
| parent | Merge pull request #353 from python-discord/F4zi/bug/LAST_EMOJI-352 (diff) | |
| parent | Cycle icons within season in configured interval only (diff) | |
Merge pull request #356 from python-discord/icon-switch-frequency
Icon switch frequency
Diffstat (limited to 'bot/seasons/season.py')
| -rw-r--r-- | bot/seasons/season.py | 15 | 
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") | 
