36 lines
976 B
Python
36 lines
976 B
Python
"""
|
|
_summary_
|
|
"""
|
|
|
|
from datetime import datetime, time
|
|
|
|
from nextcord.ext import commands, tasks
|
|
from pytz import timezone
|
|
|
|
from classes.election_cycle import ElectionCycle
|
|
|
|
|
|
class DailyLoop(commands.Cog, name="Daily Loop"):
|
|
"""
|
|
Class for performing daily functions.
|
|
"""
|
|
|
|
def __init__(self, bot: commands.Bot) -> None:
|
|
self.bot = bot
|
|
self.election = ElectionCycle(datetime(2023, 5, 25), datetime(2023, 5, 29), datetime(2023, 5, 30), self.bot)
|
|
|
|
@commands.Cog.listener()
|
|
async def on_ready(self):
|
|
"""
|
|
Starts the loop when bot is ready.
|
|
"""
|
|
await self.bot.wait_until_ready()
|
|
# pylint doesn't recognize that periodic_update_guild_data is subclassed from tasks.loop.
|
|
await self.do_thing.start() # pylint: disable=no-member
|
|
|
|
@tasks.loop(time=time(hour=0, tzinfo=timezone("GMT")))
|
|
async def do_thing(self):
|
|
""" """
|
|
print("loop")
|
|
await self.election.check_date()
|