This commit is contained in:
@@ -13,6 +13,7 @@ COPY config.py config.py
|
|||||||
COPY dakiny_bot.py dakiny_bot.py
|
COPY dakiny_bot.py dakiny_bot.py
|
||||||
COPY utils.py utils.py
|
COPY utils.py utils.py
|
||||||
|
|
||||||
|
COPY bot_messages bot_messages/
|
||||||
COPY classes classes/
|
COPY classes classes/
|
||||||
COPY cogs cogs/
|
COPY cogs cogs/
|
||||||
COPY database_setup database_setup/
|
COPY database_setup database_setup/
|
||||||
|
|||||||
+16
-12
@@ -24,18 +24,11 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
|
|||||||
|
|
||||||
def __init__(self, bot: commands.Bot) -> None:
|
def __init__(self, bot: commands.Bot) -> None:
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.current_election = self.get_current_cycle()
|
self.current_election = None
|
||||||
|
|
||||||
@commands.Cog.listener()
|
|
||||||
async def on_ready(self):
|
|
||||||
"""
|
|
||||||
Starts the loop when bot is ready.
|
|
||||||
"""
|
|
||||||
|
|
||||||
self.update_birthdays()
|
self.update_birthdays()
|
||||||
await self.bot.wait_until_ready()
|
|
||||||
# pylint doesn't recognize that periodic_update_guild_data is subclassed from tasks.loop.
|
# pylint doesn't recognize that daily_loop is subclassed from tasks.loop.
|
||||||
await self.daily_loop.start() # pylint: disable=no-member
|
self.daily_loop.start() # pylint: disable=no-member
|
||||||
|
|
||||||
@tasks.loop(time=time(hour=0, tzinfo=timezone("GMT")))
|
@tasks.loop(time=time(hour=0, tzinfo=timezone("GMT")))
|
||||||
async def daily_loop(self):
|
async def daily_loop(self):
|
||||||
@@ -55,6 +48,17 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
|
|||||||
|
|
||||||
self.update_birthdays()
|
self.update_birthdays()
|
||||||
|
|
||||||
|
@daily_loop.before_loop
|
||||||
|
async def before_loop(self):
|
||||||
|
"""
|
||||||
|
Actions run before the loop starts. Want to wait for bot to be ready and get the current cycle.
|
||||||
|
"""
|
||||||
|
|
||||||
|
await self.bot.wait_until_ready()
|
||||||
|
|
||||||
|
# Bot needs to know guilds to get the current cycle.
|
||||||
|
self.current_election = self.get_current_cycle()
|
||||||
|
|
||||||
def get_current_cycle(self) -> ElectionCycle:
|
def get_current_cycle(self) -> ElectionCycle:
|
||||||
"""
|
"""
|
||||||
Creates an object for the current election cycle if one is active. An election is considered active
|
Creates an object for the current election cycle if one is active. An election is considered active
|
||||||
@@ -70,7 +74,7 @@ class DailyLoop(commands.Cog, name="Daily Loop"):
|
|||||||
|
|
||||||
for cycle, election in enumerate(config.election_cycles):
|
for cycle, election in enumerate(config.election_cycles):
|
||||||
if (
|
if (
|
||||||
today.date() > get_datetime(election.election_start).date()
|
today.date() >= get_datetime(election.election_start).date()
|
||||||
and today.date() < get_datetime(election.term_start).date()
|
and today.date() < get_datetime(election.term_start).date()
|
||||||
):
|
):
|
||||||
current_election = ElectionCycle(cycle, config, self.bot.get_guild(config.params.guild_id))
|
current_election = ElectionCycle(cycle, config, self.bot.get_guild(config.params.guild_id))
|
||||||
|
|||||||
+3
-1
@@ -57,4 +57,6 @@ def main(cfg: DakinyConfig):
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.argv.append("hydra.job.chdir=False")
|
sys.argv.append("hydra.job.chdir=False")
|
||||||
main()
|
sys.argv.append("hydra/job_logging=none")
|
||||||
|
sys.argv.append("hydra/hydra_logging=none")
|
||||||
|
main() # pylint: disable=no-value-for-parameter
|
||||||
|
|||||||
Reference in New Issue
Block a user