Exemplo n.º 1
0
    async def branding_set(self,
                           ctx: commands.Context,
                           *,
                           season_name: t.Optional[str] = None) -> None:
        """
        Manually set season, or reset to current if none given.

        Season search is a case-less comparison against both seasonal class name,
        and its `season_name` attr.

        This only pre-loads the cog's internal state to the chosen season, but does not
        automatically apply the branding. As that is an expensive operation, the `apply`
        command must be called explicitly after this command finishes.

        This means that this command can be used to 'preview' a season gathering info
        about its available assets, without applying them to the guild.

        If the daemon is running, it will automatically reset the season to current when
        it wakes up. The season set via this command can therefore remain 'detached' from
        what it should be - the daemon will make sure that it's set back properly.
        """
        if season_name is None:
            new_season = _seasons.get_current_season()
        else:
            new_season = _seasons.get_season(season_name)
            if new_season is None:
                raise _errors.BrandingError("No such season exists")

        if self.current_season is new_season:
            raise _errors.BrandingError(
                f"Season {self.current_season.season_name} already active")

        self.current_season = new_season
        await self.branding_refresh(ctx)
Exemplo n.º 2
0
    async def daemon_stop(self, ctx: commands.Context) -> None:
        """If the daemon is running, stop it."""
        if not self._daemon_running:
            raise _errors.BrandingError("Daemon not running!")

        self.daemon.cancel()
        await self.branding_configuration.set("daemon_active", False)

        response = discord.Embed(
            description=f"Daemon stopped {Emojis.ok_hand}",
            colour=Colours.soft_green)
        await ctx.send(embed=response)
Exemplo n.º 3
0
    async def daemon_start(self, ctx: commands.Context) -> None:
        """If the daemon isn't running, start it."""
        if self._daemon_running:
            raise _errors.BrandingError("Daemon already running!")

        self.daemon = self.bot.loop.create_task(self._daemon_func())
        await self.branding_configuration.set("daemon_active", True)

        response = discord.Embed(
            description=f"Daemon started {Emojis.ok_hand}",
            colour=Colours.soft_green)
        await ctx.send(embed=response)
Exemplo n.º 4
0
    async def branding_cycle(self, ctx: commands.Context) -> None:
        """
        Apply the next-up guild icon, if multiple are available.

        The order is random.
        """
        async with ctx.typing():
            success = await self.cycle()
            if not success:
                raise _errors.BrandingError("Failed to cycle icon")

            response = discord.Embed(description=f"Success {Emojis.ok_hand}",
                                     colour=Colours.soft_green)
            await ctx.send(embed=response)
Exemplo n.º 5
0
    async def branding_apply(self, ctx: commands.Context) -> None:
        """
        Apply current season's branding to the guild.

        Use `info` to check which assets will be applied. Shows which assets have
        failed to be applied, if any.
        """
        async with ctx.typing():
            failed_assets = await self.apply()
            if failed_assets:
                raise _errors.BrandingError(
                    f"Failed to apply following assets: {', '.join(failed_assets)}"
                )

            response = discord.Embed(
                description=f"All assets applied {Emojis.ok_hand}",
                colour=Colours.soft_green)
            await ctx.send(embed=response)