aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar kwzrd <[email protected]>2020-03-07 12:59:45 +0100
committerGravatar kwzrd <[email protected]>2020-03-07 12:59:45 +0100
commit3657fd856ba57687083d3bc541b41d8cd87b460c (patch)
tree3a03ecc6a315c98df2cfefb517ac631c5137240e
parentImplement in_month command check (diff)
Deseasonify: remove SeasonManager cog
-rw-r--r--bot/seasons/__init__.py7
-rw-r--r--bot/seasons/season.py132
2 files changed, 1 insertions, 138 deletions
diff --git a/bot/seasons/__init__.py b/bot/seasons/__init__.py
index 7faf9164..ffbf8add 100644
--- a/bot/seasons/__init__.py
+++ b/bot/seasons/__init__.py
@@ -2,13 +2,8 @@ import logging
from discord.ext import commands
-from bot.seasons.season import SeasonBase, SeasonManager, get_season
+from bot.seasons.season import SeasonBase, get_season
__all__ = ("SeasonBase", "get_season")
log = logging.getLogger(__name__)
-
-
-def setup(bot: commands.Bot) -> None:
- bot.add_cog(SeasonManager(bot))
- log.info("SeasonManager cog loaded")
diff --git a/bot/seasons/season.py b/bot/seasons/season.py
index 2ebe3e63..83fa3f31 100644
--- a/bot/seasons/season.py
+++ b/bot/seasons/season.py
@@ -267,135 +267,3 @@ class SeasonBase:
log.info(f"Skipping season announcement due to username not being changed.")
await bot.send_log("SeasonalBot Loaded!", f"Active Season: **{self.name_clean}**")
-
-
-class SeasonManager(commands.Cog):
- """A cog for managing seasons."""
-
- def __init__(self, bot: commands.Bot):
- self.bot = bot
- season_class = get_season_class("evergreen")
- self.season = season_class()
- self.season_task = bot.loop.create_task(self.season.load())
-
- @with_role(Roles.moderator, Roles.admin, Roles.owner)
- @commands.command(name="season")
- async def change_season(self, ctx: commands.Context, new_season: str) -> None:
- """Changes the currently active season on the bot."""
- self.season = get_season(season_name=new_season)
- await self.season.load()
- await ctx.send(f"Season changed to {new_season}.")
-
- @with_role(Roles.moderator, Roles.admin, Roles.owner)
- @commands.command(name="seasons")
- async def show_seasons(self, ctx: commands.Context) -> None:
- """Shows the available seasons and their dates."""
- # Sort by start order, followed by lower duration
- def season_key(season_class: Type[SeasonBase]) -> Tuple[datetime.datetime, datetime.timedelta]:
- return season_class.start(), season_class.end() - datetime.datetime.max
-
- current_season = self.season.name
-
- forced_space = "\u200b "
-
- entries = []
- seasons = [get_season_class(s) for s in get_seasons()]
- for season in sorted(seasons, key=season_key):
- start = season.start_date
- end = season.end_date
- if start and not end:
- period = f"From {start}"
- elif end and not start:
- period = f"Until {end}"
- elif not end and not start:
- period = f"Always"
- else:
- period = f"{start} to {end}"
-
- # Bold period if current date matches season date range
- is_current = season.is_between_dates(datetime.datetime.utcnow())
- pdec = "**" if is_current else ""
-
- # Underline currently active season
- is_active = current_season == season.name
- sdec = "__" if is_active else ""
-
- entries.append(
- f"**{sdec}{season.__name__}:{sdec}**\n"
- f"{forced_space*3}{pdec}{period}{pdec}\n"
- )
-
- embed = discord.Embed(description="\n".join(entries), colour=ctx.guild.me.colour)
- embed.set_author(name="Seasons")
- await ctx.send(embed=embed)
-
- @with_role(Roles.moderator, Roles.admin, Roles.owner)
- @commands.group()
- async def set(self, ctx: commands.Context) -> None:
- """Change aspects of the bot or server."""
- if not ctx.invoked_subcommand:
- await ctx.send_help(ctx.command)
-
- @set.command(name="avatar", aliases=["avy"])
- async def set_avatar(self, ctx: commands.Context, *, image_url: str = None) -> None:
- """Sets the bot avatar."""
- if not image_url:
- image_url = f"{ICON_BASE_URL}/logos/logo_seasonal/evergreen/logo_evergreen.png"
- elif image_url.startswith("<"):
- image_url = image_url.strip("<>")
-
- is_changed = await ctx.bot.set_avatar(image_url)
-
- embed = discord.Embed(
- title="Avatar changed." if is_changed else "Avatar change failed.",
- colour=discord.Colour.green() if is_changed else discord.Colour.red()
- )
- await ctx.send(embed=embed)
-
- @set.command(name="icon")
- async def set_server_icon(self, ctx: commands.Context, *, image_url: str = None) -> None:
- """Sets the server icon."""
- if not image_url:
- image_url = f"{ICON_BASE_URL}/logos/logo_full/logo_full.png"
- elif image_url.startswith("<"):
- image_url = image_url.strip("<>")
-
- is_changed = await ctx.bot.set_icon(image_url)
-
- embed = discord.Embed(
- title="Server icon changed." if is_changed else "Server icon change failed.",
- colour=discord.Colour.green() if is_changed else discord.Colour.red()
- )
- await ctx.send(embed=embed)
-
- @set.command(name="username", aliases=["name"])
- async def set_username(self, ctx: commands.Context, *, new_name: str = None) -> None:
- """Sets the bot username."""
- new_name = new_name or "SeasonalBot"
- is_changed = await ctx.bot.set_username(new_name)
-
- if is_changed:
- title = f"Username changed to {new_name}"
- else:
- if is_changed is False:
- title = f"Username change failed, Nickname changed to {new_name} instead."
- else:
- title = "Username change failed."
-
- embed = discord.Embed(
- colour=discord.Colour.green() if is_changed else discord.Colour.red(),
- title=title
- )
- await ctx.send(embed=embed)
-
- @set.command(name="nickname", aliases=["nick"])
- async def set_nickname(self, ctx: commands.Context, *, new_name: str = None) -> None:
- """Sets the bot nickname."""
- new_name = new_name or "SeasonalBot"
- is_changed = await ctx.bot.set_nickname(new_name)
-
- embed = discord.Embed(
- colour=discord.Colour.green() if is_changed else discord.Colour.red(),
- title=f"Nickname changed to {new_name}" if is_changed else "Nickname change failed."
- )
- await ctx.send(embed=embed)