Set up bot to do initial test. Made changes in class to make test take less time.
This commit is contained in:
+37
-11
@@ -4,6 +4,7 @@ Contains the election cycle class
|
||||
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
import nextcord
|
||||
from nextcord.ext import commands
|
||||
|
||||
|
||||
@@ -26,12 +27,12 @@ class ElectionCycle:
|
||||
self._election_start: datetime = election_start
|
||||
self._term_start: datetime = term_start
|
||||
self._term_end: datetime = term_end # might not be needed
|
||||
self._voting_start: datetime = self._election_start + timedelta(days=7)
|
||||
self._voting_end: datetime = self._voting_start + timedelta(days=7)
|
||||
self._voting_start: datetime = self._election_start + timedelta(days=1)
|
||||
self._voting_end: datetime = self._voting_start + timedelta(days=1)
|
||||
self._highcouncil_election: datetime = self._voting_end + timedelta(days=1)
|
||||
self._bot: commands.Bot = bot
|
||||
|
||||
def check_date(self) -> None:
|
||||
async def check_date(self) -> None:
|
||||
"""
|
||||
Function checks current date to see if something needs to be run.
|
||||
"""
|
||||
@@ -40,34 +41,59 @@ class ElectionCycle:
|
||||
# check all dates if action is needed
|
||||
match today.date():
|
||||
case self._election_start.date():
|
||||
self.election_start_action()
|
||||
await self.election_start_action()
|
||||
case self._voting_start.date():
|
||||
self.voting_end_action()
|
||||
await self.voting_end_action()
|
||||
case self._voting_end.date():
|
||||
self.voting_end_action()
|
||||
await self.voting_end_action()
|
||||
case self._highcouncil_election.date():
|
||||
self.highcouncil_election_action()
|
||||
await self.highcouncil_election_action()
|
||||
case self._term_start.date():
|
||||
await self.term_start_action()
|
||||
case self._term_end.date():
|
||||
await self.term_end_action()
|
||||
|
||||
def election_start_action(self) -> None:
|
||||
async def election_start_action(self) -> None:
|
||||
"""
|
||||
Performs required actions for when the election cycle starts.
|
||||
"""
|
||||
print("election cycle has started")
|
||||
await self.message_me("election cycle has started")
|
||||
|
||||
def voting_start_action(self) -> None:
|
||||
async def voting_start_action(self) -> None:
|
||||
"""
|
||||
Performs required actions for when voting for candidates starts.
|
||||
"""
|
||||
print("Voting has started")
|
||||
await self.message_me("Voting has started")
|
||||
|
||||
def voting_end_action(self) -> None:
|
||||
async def voting_end_action(self) -> None:
|
||||
"""
|
||||
Performs required actions for when voting time has ended.
|
||||
"""
|
||||
print("voting has ended")
|
||||
await self.message_me("voting has ended")
|
||||
|
||||
def highcouncil_election_action(self) -> None:
|
||||
async def highcouncil_election_action(self) -> None:
|
||||
"""
|
||||
Performs required actions for when the highcouncil is elected.
|
||||
"""
|
||||
print("Highcouncil election has started.")
|
||||
await self.message_me("Highcouncil election has started.")
|
||||
|
||||
async def term_start_action(self) -> None:
|
||||
msg: str = "the term has started"
|
||||
print(msg)
|
||||
self.message_me(msg)
|
||||
|
||||
async def term_end_action(self):
|
||||
msg: str = "the term has ended"
|
||||
print(msg)
|
||||
self.message_me(msg)
|
||||
|
||||
async def message_me(self, msg: str):
|
||||
"""
|
||||
message a string to me
|
||||
"""
|
||||
imcompiling: nextcord.User = await self._bot.fetch_user(206602713511886849)
|
||||
await imcompiling.send(msg)
|
||||
|
||||
Reference in New Issue
Block a user