Compare commits

...
7 Commits
Author SHA1 Message Date
imcompiling d7a0480c2b Merge branch '78-config-for-skipping-election-cycle'
build_latest / build (push) Successful in 17s
build_release / build (push) Successful in 17s
build_develop / build (push) Has been cancelled
2024-09-07 15:49:21 -04:00
imcompiling 8457c09b5b Remove bad import.
build_develop / build (push) Successful in 1m24s
2024-09-07 15:46:52 -04:00
imcompiling 3c31d0ad33 Add active parameter to elections. Only return an election for use if the election is active. 2024-09-07 15:46:30 -04:00
imcompiling 70676a98dd Merge branch '77-verification-for-splits'
build_latest / build (push) Successful in 16s
build_release / build (push) Successful in 16s
2024-09-07 15:15:26 -04:00
imcompiling 512802def7 Add ability to configure event verification.
build_develop / build (push) Successful in 1m22s
2024-09-07 15:14:50 -04:00
imcompiling 87b21782ce Remove unneeded import. 2024-09-07 15:08:53 -04:00
imcompiling 38ef2f4cb8 process_event isn't part of the class anymore. 2024-09-07 15:07:59 -04:00
7 changed files with 44 additions and 20 deletions
+1
View File
@@ -23,6 +23,7 @@ class ChannelIds:
class Election: class Election:
"""Class defines relevant election dates.""" """Class defines relevant election dates."""
active: bool
election_start: str election_start: str
highcouncil_election_announce: str highcouncil_election_announce: str
highcouncil_election_end: str highcouncil_election_end: str
+1
View File
@@ -49,6 +49,7 @@ class Election:
""" """
self.cycle = cycle self.cycle = cycle
self.election_cycle = settings.election_cycles[self.cycle] self.election_cycle = settings.election_cycles[self.cycle]
self.active = self.election_cycle.active
self.election_start: datetime = get_datetime(self.election_cycle.election_start) self.election_start: datetime = get_datetime(self.election_cycle.election_start)
self.term_start: datetime = get_datetime(self.election_cycle.term_start) self.term_start: datetime = get_datetime(self.election_cycle.term_start)
self.term_end: datetime = get_datetime(self.election_cycle.term_end) self.term_end: datetime = get_datetime(self.election_cycle.term_end)
+1 -3
View File
@@ -1,7 +1,5 @@
"""Contained commands and views for record commands.""" """Contained commands and views for record commands."""
from typing import List
import nextcord import nextcord
from discord import TextInputStyle from discord import TextInputStyle
from nextcord.ext import commands from nextcord.ext import commands
@@ -192,7 +190,7 @@ class EventView(nextcord.ui.View):
) )
submission_response = "Event has been submitted to admins for approval." submission_response = "Event has been submitted to admins for approval."
else: else:
self.process_event( process_event(
self.event_participants.values.members, self.event_participants.values.members,
interaction.message.embeds[0].fields[1].value, interaction.message.embeds[0].fields[1].value,
self.host_id, self.host_id,
+23 -3
View File
@@ -160,7 +160,7 @@ class SettingsCog(commands.Cog, name="Settings Commands"):
Args: Args:
interaction (nextcord.Interaction): Discord interaction of command. interaction (nextcord.Interaction): Discord interaction of command.
points (nextcord.TextChannel): Number of points to set. points (int): Number of points to set.
""" """
settings.event_settings.host_points = points settings.event_settings.host_points = points
settings.save() settings.save()
@@ -181,12 +181,32 @@ class SettingsCog(commands.Cog, name="Settings Commands"):
Args: Args:
interaction (nextcord.Interaction): Discord interaction of command. interaction (nextcord.Interaction): Discord interaction of command.
points (nextcord.TextChannel): Number of points to set. points (int): Number of points to set.
""" """
settings.event_settings.participate_points = points settings.event_settings.participate_points = points
settings.save() settings.save()
await interaction.response.send_message(f"Event Participation Points set to {points}.", ephemeral=True) await interaction.response.send_message(f"Event Participation Points set to {points}.", ephemeral=True)
@event_settings.subcommand(description="Sets Event Participation Points value.")
async def verify(
self,
interaction: nextcord.Interaction,
do_verification: bool = nextcord.SlashOption( # noqa: FBT001
required=True,
description="Whether an event should be verified or not.",
),
) -> None:
"""
Sets DakinySettings event_settings.verify to the given number of points.
Args:
interaction (nextcord.Interaction): Discord interaction of command.
do_verification (bool): If the bot should verify events.
"""
settings.event_settings.verify = do_verification
settings.save()
await interaction.response.send_message(f"Event verification set to {do_verification}.", ephemeral=True)
@event_settings.subcommand(description="Sets Event Weekly Limit value.") @event_settings.subcommand(description="Sets Event Weekly Limit value.")
async def weekly_limit( async def weekly_limit(
self, self,
@@ -200,7 +220,7 @@ class SettingsCog(commands.Cog, name="Settings Commands"):
Args: Args:
interaction (nextcord.Interaction): Discord interaction of command. interaction (nextcord.Interaction): Discord interaction of command.
points (nextcord.TextChannel): Number of points to set. points (int): Number of points to set.
""" """
settings.event_settings.weekly_limit = points settings.event_settings.weekly_limit = points
settings.save() settings.save()
+8 -8
View File
@@ -5,7 +5,7 @@ from nextcord.ext import application_checks, commands
from classes.election import Election from classes.election import Election
from DakinySettings import settings from DakinySettings import settings
from utils import GUILDS, get_current_election_cycle from utils import GUILDS, get_active_election_cycle
ME = 206602713511886849 ME = 206602713511886849
@@ -40,7 +40,7 @@ class TestCog(commands.Cog, name="Test commands."):
interaction (nextcord.Interaction): Interaction with the message. interaction (nextcord.Interaction): Interaction with the message.
""" """
cycle = Election( cycle = Election(
get_current_election_cycle(), get_active_election_cycle(),
self.bot.get_guild(settings.params.guild_id), self.bot.get_guild(settings.params.guild_id),
) )
await cycle.election_start_action() await cycle.election_start_action()
@@ -56,7 +56,7 @@ class TestCog(commands.Cog, name="Test commands."):
interaction (nextcord.Interaction): Interaction with the message. interaction (nextcord.Interaction): Interaction with the message.
""" """
cycle = Election( cycle = Election(
get_current_election_cycle(), get_active_election_cycle(),
self.bot.get_guild(settings.params.guild_id), self.bot.get_guild(settings.params.guild_id),
) )
await cycle.voting_start_action() await cycle.voting_start_action()
@@ -72,7 +72,7 @@ class TestCog(commands.Cog, name="Test commands."):
interaction (nextcord.Interaction): Interaction with the message. interaction (nextcord.Interaction): Interaction with the message.
""" """
cycle = Election( cycle = Election(
get_current_election_cycle(), get_active_election_cycle(),
self.bot.get_guild(settings.params.guild_id), self.bot.get_guild(settings.params.guild_id),
) )
await cycle.voting_end_action() await cycle.voting_end_action()
@@ -88,7 +88,7 @@ class TestCog(commands.Cog, name="Test commands."):
interaction (nextcord.Interaction): Interaction with the message. interaction (nextcord.Interaction): Interaction with the message.
""" """
cycle = Election( cycle = Election(
get_current_election_cycle(), get_active_election_cycle(),
self.bot.get_guild(settings.params.guild_id), self.bot.get_guild(settings.params.guild_id),
) )
await cycle.highcouncil_election_start_action() await cycle.highcouncil_election_start_action()
@@ -104,7 +104,7 @@ class TestCog(commands.Cog, name="Test commands."):
interaction (nextcord.Interaction): Interaction with the message. interaction (nextcord.Interaction): Interaction with the message.
""" """
cycle = Election( cycle = Election(
get_current_election_cycle(), get_active_election_cycle(),
self.bot.get_guild(settings.params.guild_id), self.bot.get_guild(settings.params.guild_id),
) )
await cycle.election_reminder() await cycle.election_reminder()
@@ -120,7 +120,7 @@ class TestCog(commands.Cog, name="Test commands."):
interaction (nextcord.Interaction): Interaction with the message. interaction (nextcord.Interaction): Interaction with the message.
""" """
cycle = Election( cycle = Election(
get_current_election_cycle(), get_active_election_cycle(),
self.bot.get_guild(settings.params.guild_id), self.bot.get_guild(settings.params.guild_id),
) )
await cycle.check_date() await cycle.check_date()
@@ -136,7 +136,7 @@ class TestCog(commands.Cog, name="Test commands."):
interaction (nextcord.Interaction): Interaction with the message. interaction (nextcord.Interaction): Interaction with the message.
""" """
cycle = Election( cycle = Election(
get_current_election_cycle(), get_active_election_cycle(),
self.bot.get_guild(settings.params.guild_id), self.bot.get_guild(settings.params.guild_id),
) )
await cycle.term_start_action() await cycle.term_start_action()
+5 -3
View File
@@ -13,7 +13,7 @@ from classes.election import Election
from DakinySettings import settings from DakinySettings import settings
from database_setup.sql_data_classes import UserBirthday, engine from database_setup.sql_data_classes import UserBirthday, engine
from main import birthday_list from main import birthday_list
from utils import get_current_election_cycle from utils import get_active_election_cycle
if TYPE_CHECKING: if TYPE_CHECKING:
import nextcord import nextcord
@@ -75,13 +75,15 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
Returns: Returns:
Election: Current election cycle, None if there is no election happening. Election: Current election cycle, None if there is no election happening.
""" """
cycle = get_current_election_cycle() cycle = get_active_election_cycle()
# prevent exception from using cycle as an Int in an array # prevent exception from using cycle as an Int in an array
if cycle is None: if cycle is None:
return None return None
return Election(cycle, self.bot.get_guild(settings.params.guild_id)) election = Election(cycle, self.bot.get_guild(settings.params.guild_id))
return election if election.active else None
def update_birthdays(self) -> None: def update_birthdays(self) -> None:
"""Goes through database to collect all birthdays that are today. Adds user's id to birthday list.""" """Goes through database to collect all birthdays that are today. Adds user's id to birthday list."""
+5 -3
View File
@@ -64,7 +64,7 @@ def get_election_name() -> str:
Returns: Returns:
str: the name of the election cycle str: the name of the election cycle
""" """
cycle = get_current_election_cycle() cycle = get_active_election_cycle()
current_cycle = settings.election_cycles[cycle] current_cycle = settings.election_cycles[cycle]
return f"vote-{get_datetime(current_cycle.term_start).year}-{current_cycle.name}" return f"vote-{get_datetime(current_cycle.term_start).year}-{current_cycle.name}"
@@ -82,7 +82,7 @@ def get_quarter_name() -> str:
return f"{get_datetime(current_cycle.term_start).year}-{current_cycle.name}" return f"{get_datetime(current_cycle.term_start).year}-{current_cycle.name}"
def get_current_election_cycle() -> int: def get_active_election_cycle() -> int:
""" """
Returns index for active election. An election is considered active between the election start and the term start. Returns index for active election. An election is considered active between the election start and the term start.
@@ -104,7 +104,9 @@ def get_current_election_cycle() -> int:
def get_quarter_cycle() -> int: def get_quarter_cycle() -> int:
""" """
Returns the index for the current cycle/quarter. Defined as between term start and end. Shouldn't return none. Returns the index for the current cycle/quarter. Defined as between term start and end.
Can return None if entire year isn't covered by cycles.
Returns: Returns:
int: cycle index for current cycle. int: cycle index for current cycle.