Add active parameter to elections. Only return an election for use if the election is active.
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import random
|
||||
from datetime import UTC, datetime, time
|
||||
from tkinter import NO
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from nextcord.ext import commands, tasks
|
||||
@@ -13,7 +14,7 @@ from classes.election import Election
|
||||
from DakinySettings import settings
|
||||
from database_setup.sql_data_classes import UserBirthday, engine
|
||||
from main import birthday_list
|
||||
from utils import get_current_election_cycle
|
||||
from utils import get_active_election_cycle
|
||||
|
||||
if TYPE_CHECKING:
|
||||
import nextcord
|
||||
@@ -75,13 +76,15 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
|
||||
Returns:
|
||||
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
|
||||
if cycle is 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:
|
||||
"""Goes through database to collect all birthdays that are today. Adds user's id to birthday list."""
|
||||
|
||||
Reference in New Issue
Block a user