diff options
author | 2020-03-19 23:56:25 +0100 | |
---|---|---|
committer | 2020-03-19 23:56:25 +0100 | |
commit | 18eb4317bf9b1647b51471a79a8e101119e69b02 (patch) | |
tree | 92a47fb7dde663a6af4a1b68b27900feb8f5a7c3 | |
parent | Deseasonify: turn legacy docstrings into attrs (diff) |
Deseasonify: improve branding embed
This improves both the visual embed, and the code used to generate it.
We'll now only display active months if the current season isn't the
evergreen - no reason to list the 12 months. The season's name and
avatar will be shown in the author field, as this is more less
aggressive and more visually pleasing than using title + thumbnail.
The embed will be coloured using the season's colour attr.
All values have safe fall-backs for situations where the seasonal
assets have failed to load.
-rw-r--r-- | bot/branding.py | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/bot/branding.py b/bot/branding.py index bc0908b0..b07ca4b4 100644 --- a/bot/branding.py +++ b/bot/branding.py @@ -6,6 +6,7 @@ import typing as t from datetime import datetime, time, timedelta import discord +from discord.embeds import EmptyEmbed from discord.ext import commands from bot.bot import SeasonalBot @@ -131,21 +132,29 @@ class BrandingManager(commands.Cog): await asyncio.sleep(await seconds_until_midnight()) async def _info_embed(self) -> discord.Embed: - """Make an informative embed representing current state.""" - info_embed = discord.Embed( - title=self.current_season.season_name, - description=f"Active in {', '.join(m.name for m in self.current_season.months)}", - ).add_field( - name="Banner", - value=self.banner.path if self.banner is not None else "Unavailable", - ).add_field( - name="Avatar", - value=self.avatar.path if self.avatar is not None else "Unavailable", - ).add_field( - name="Available icons", - value=await pretty_files(self.available_icons) or "Unavailable", - inline=False, - ) + """Make an informative embed representing current season.""" + info_embed = discord.Embed(description=self.current_season.description, colour=self.current_season.colour) + + # If we're in a non-evergreen season, also show active months + if self.current_season is not SeasonBase: + active_months = ", ".join(m.name for m in self.current_season.months) + title = f"{self.current_season.season_name} ({active_months})" + else: + title = self.current_season.season_name + + # Use the author field to show the season's name and avatar if available + info_embed.set_author(name=title, icon_url=self.avatar.download_url if self.avatar else EmptyEmbed) + + banner = self.banner.path if self.banner is not None else "Unavailable" + info_embed.add_field(name="Banner", value=banner, inline=False) + + avatar = self.avatar.path if self.avatar is not None else "Unavailable" + info_embed.add_field(name="Avatar", value=avatar, inline=False) + + icons = await pretty_files(self.available_icons) or "Unavailable" + info_embed.add_field(name="Available icons", value=icons, inline=False) + + # Only display cycle frequency if we're actually cycling if len(self.available_icons) > 1 and Client.icon_cycle_frequency: info_embed.set_footer(text=f"Icon cycle frequency: {Client.icon_cycle_frequency}") |