This commit is contained in:
@@ -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():
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user