aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2021-03-14 00:07:14 +0100
committerGravatar kwzrd <[email protected]>2021-03-14 00:07:14 +0100
commita48e79a5ee108b47914029513a4d5cd1fa4b72a6 (patch)
treeb0bbbc1b06d136cae66b060c14a06d3a4856c929
parentBranding: replace ugly lambda with 'attrgetter' (diff)
Branding: do not call 'rotate_icons' from rotation init
It makes more sense for the init and the rotation to be separate operations. In a subsequent commit, the separation of responsibility will allow the `rotate_icons` function to have a meaningful return value.
-rw-r--r--bot/exts/backend/branding/_cog.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/bot/exts/backend/branding/_cog.py b/bot/exts/backend/branding/_cog.py
index df0ef2a5f..cd645fba4 100644
--- a/bot/exts/backend/branding/_cog.py
+++ b/bot/exts/backend/branding/_cog.py
@@ -208,6 +208,8 @@ class Branding(commands.Cog):
This function should be called whenever the set of `available_icons` changes. This is generally the case
when we enter a new event, but potentially also when the assets of an on-going event change. In such cases,
a reset of `cache_icons` is necessary, because it contains download URLs which may have gotten stale.
+
+ This function does not upload a new icon!
"""
log.debug("Initiating new icon rotation")
@@ -218,7 +220,6 @@ class Branding(commands.Cog):
log.trace(f"Icon rotation initiated for {len(new_state)} icons")
- await self.rotate_icons()
await self.cache_information.set("icons_hash", compound_hash(available_icons))
async def send_info_embed(self, channel_id: int) -> None:
@@ -266,7 +267,9 @@ class Branding(commands.Cog):
log.debug(f"Entering new event: {event.path}")
await self.apply_banner(event.banner) # Only one asset ~ apply directly
- await self.initiate_icon_rotation(event.icons) # Extra layer of abstraction to handle multiple assets
+
+ await self.initiate_icon_rotation(event.icons) # Prepare a new rotation
+ await self.rotate_icons() # Apply an icon from the new rotation
# Cache event identity to avoid re-entry in case of restart
await self.cache_information.set("event_path", event.path)
@@ -384,6 +387,7 @@ class Branding(commands.Cog):
if compound_hash(new_event.icons) != await self.cache_information.get("icons_hash"):
log.debug("Detected same-event icon change!")
await self.initiate_icon_rotation(new_event.icons)
+ await self.rotate_icons()
else:
await self.maybe_rotate_icons()