diff options
author | 2020-03-22 17:59:33 +0100 | |
---|---|---|
committer | 2020-03-22 18:08:13 +0100 | |
commit | f31e3819c9f8bfa33157810eb04a095b3d1a181c (patch) | |
tree | 6a909c490e318ec218bfb5694f5db03c742a6be1 | |
parent | Deseasonify: uncomment API calls (diff) |
Deseasonify: return failed assets
As the `apply` method attempts to apply all 4 types of assets, it is
useful to know which (if any) have failed. As all the methods that we
delegate to already return a bool denoting whether the operation has
succeeded, we can simply collect this information and return it to
the caller.
-rw-r--r-- | bot/branding.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/bot/branding.py b/bot/branding.py index c3a26b06..d9f1373a 100644 --- a/bot/branding.py +++ b/bot/branding.py @@ -280,23 +280,34 @@ class BrandingManager(commands.Cog): return success - async def apply(self) -> None: + async def apply(self) -> t.List[str]: """ Apply current branding to the guild and bot. This delegates to the bot instance to do all the work. We only provide download urls for available assets. Assets unavailable in the branding repo will be ignored. + + Returns a list of names of all failed assets. An asset is considered failed + if it isn't found in the branding repo, or if something goes wrong while the + bot is trying to apply it. + + An empty list denotes that all assets have been applied successfully. """ + report = {asset: False for asset in ("banner", "avatar", "nickname", "icon")} + if self.banner is not None: - await self.bot.set_banner(self.banner.download_url) + report["banner"] = await self.bot.set_banner(self.banner.download_url) if self.avatar is not None: - await self.bot.set_avatar(self.avatar.download_url) + report["avatar"] = await self.bot.set_avatar(self.avatar.download_url) if self.current_season.bot_name: - await self.bot.set_nickname(self.current_season.bot_name) + report["nickname"] = await self.bot.set_nickname(self.current_season.bot_name) + + report["icon"] = await self.cycle() - await self.cycle() + failed_assets = [asset for asset, succeeded in report.items() if not succeeded] + return failed_assets @with_role(*MODERATION_ROLES) @commands.group(name="branding") |