diff --git a/classes/election_cycle.py b/classes/election_cycle.py index 461ebd2..6b3dc89 100644 --- a/classes/election_cycle.py +++ b/classes/election_cycle.py @@ -143,7 +143,7 @@ class ElectionCycle: async def check_date(self) -> None: """Function checks current date to see if something needs to be run.""" - today = datetime.now(tz=UTC).date() + today = datetime.now(tz=UTC) # check all dates if action is needed if today.date() == self.election_start.date(): diff --git a/cogs/commands/set.py b/cogs/commands/set.py index 01c35ed..2165241 100644 --- a/cogs/commands/set.py +++ b/cogs/commands/set.py @@ -49,7 +49,7 @@ class SetCog(commands.Cog, name="Set Commands"): return # check if valid day - today = datetime.now(tz=UTC).date() + today = datetime.now(tz=UTC) try: birthday = datetime(today.year, month, day, tzinfo=UTC) except ValueError: diff --git a/cogs/commands/test.py b/cogs/commands/test.py index bc13e73..1e93b1e 100644 --- a/cogs/commands/test.py +++ b/cogs/commands/test.py @@ -4,7 +4,6 @@ from typing import TYPE_CHECKING import nextcord from nextcord.ext import application_checks, commands -from nextcord.ext.application_checks.core import AC from classes.election_cycle import ElectionCycle from utils import get_current_election_cycle @@ -17,7 +16,7 @@ ME = 206602713511886849 GUILDS = [1000247361639030804] -def is_me() -> AC: +def is_me(): # noqa: ANN201 """Predicate that makes sure only I can run the test commands.""" def predicate(interaction: nextcord.Interaction) -> bool: @@ -53,7 +52,7 @@ class TestCog(commands.Cog, name="Test commands."): self.bot.get_guild(config.params.guild_id), ) await cycle.election_start_action() - await interaction.send("Test command sent.") + await interaction.send("Test command sent.", ephemeral=True) @test.subcommand() @is_me() @@ -71,7 +70,7 @@ class TestCog(commands.Cog, name="Test commands."): self.bot.get_guild(config.params.guild_id), ) await cycle.voting_start_action() - await interaction.send("Test command sent.") + await interaction.send("Test command sent.", ephemeral=True) @test.subcommand() @is_me() @@ -89,7 +88,7 @@ class TestCog(commands.Cog, name="Test commands."): self.bot.get_guild(config.params.guild_id), ) await cycle.voting_end_action() - await interaction.send("Test command sent.") + await interaction.send("Test command sent.", ephemeral=True) @test.subcommand() @is_me() @@ -107,7 +106,7 @@ class TestCog(commands.Cog, name="Test commands."): self.bot.get_guild(config.params.guild_id), ) await cycle.highcouncil_election_start_action() - await interaction.send("Test command sent.") + await interaction.send("Test command sent.", ephemeral=True) @test.subcommand() @is_me() @@ -125,7 +124,7 @@ class TestCog(commands.Cog, name="Test commands."): self.bot.get_guild(config.params.guild_id), ) await cycle.election_reminder() - await interaction.send("Test command sent.") + await interaction.send("Test command sent.", ephemeral=True) @test.subcommand() @is_me() @@ -143,7 +142,7 @@ class TestCog(commands.Cog, name="Test commands."): self.bot.get_guild(config.params.guild_id), ) await cycle.check_date() - await interaction.send("Test command sent.") + await interaction.send("Test command sent.", ephemeral=True) @test.subcommand() @is_me() @@ -161,4 +160,4 @@ class TestCog(commands.Cog, name="Test commands."): self.bot.get_guild(config.params.guild_id), ) await cycle.term_start_action() - await interaction.send("Test command sent.") + await interaction.send("Test command sent.", ephemeral=True) diff --git a/utils.py b/utils.py index 9ad7d76..13e17e9 100644 --- a/utils.py +++ b/utils.py @@ -47,10 +47,12 @@ def get_datetime(day: str) -> datetime: day = int(day.split("/")[1]) # ensure that year rolls over if current month is December and the next month is less than 12. - if today.month == calendar.DECEMBER and month < calendar.DECEMBER: + # TODO(imcompiling): replace with Calendar.DECEMBER when updating to python 3.12 + # https://gitea.cheezers.org/imcompiling/dakiny-bot/issues/52 + if today.month == 12 and month < 12: year += 1 - if today.month == calendar.JANUARY and month > calendar.JANUARY: + if today.month == 1 and month > 1: year -= 1 return datetime(year, month, day, tzinfo=UTC) @@ -97,7 +99,7 @@ def get_current_election_cycle(config: DakinyConfig) -> int: Returns: int: cycle index for active election. None for no active cycle """ - today = datetime.now(tz=UTC).date() + today = datetime.now(tz=UTC) for cycle, election in enumerate(config.election_cycles): if ( @@ -120,7 +122,7 @@ def get_quarter_cycle(config: DakinyConfig) -> int: Returns: int: cycle index for current cycle. """ - today = datetime.now(tz=UTC).date() + today = datetime.now(tz=UTC) for cycle, election in enumerate(config.election_cycles): if ( today.date() >= get_datetime(election.term_start).date()