Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0eae8afa2a | ||
|
|
d79c990558 | ||
|
|
3465698b85 | ||
|
|
1731bd46a6 | ||
|
|
1b4c5780df | ||
|
|
d67940aa26 | ||
|
|
9867f91268 | ||
|
|
4763651e93 | ||
|
|
1c76e6806c | ||
|
|
5cb9be7e37 | ||
|
|
d573595114 |
@@ -10,4 +10,4 @@ From {highcouncil_election_announce} to {highcouncil_election_start}, you will b
|
|||||||
Each member of the CCE can cast one for each category by using the emotes: <:Rank_Owner:479008325137072155> for Clan Leader and <:Rank_Deputy:479008295319896064> for Discord Server Manager.
|
Each member of the CCE can cast one for each category by using the emotes: <:Rank_Owner:479008325137072155> for Clan Leader and <:Rank_Deputy:479008295319896064> for Discord Server Manager.
|
||||||
If needed, the icon 🤷 can be used to abstain to vote in any or both categories and it should be apply to all candidates of that category.
|
If needed, the icon 🤷 can be used to abstain to vote in any or both categories and it should be apply to all candidates of that category.
|
||||||
|
|
||||||
Votes can be cast until the {highcouncil_election_end}, so we can announce and have everyone set up to start the term by {term_start}
|
Votes can be cast until the {highcouncil_election_end}, so we can announce and have everyone set up to start the term by {term_start}.
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
<@&{clan_council_elect_role_id}> it is now time to vote for the high council! You have until {term_start} to complete the vote.
|
||||||
+57
-20
@@ -71,7 +71,7 @@ class ElectionCycle:
|
|||||||
|
|
||||||
return message.split("---message_break---")
|
return message.split("---message_break---")
|
||||||
|
|
||||||
def build_highcouncil_election(self) -> str:
|
def build_highcouncil_election_announce(self) -> str:
|
||||||
"""
|
"""
|
||||||
Builds message to announce highcouncil election start.
|
Builds message to announce highcouncil election start.
|
||||||
|
|
||||||
@@ -82,7 +82,29 @@ class ElectionCycle:
|
|||||||
with open("bot_messages/highcouncil_election.txt", mode="r", encoding="utf8") as file:
|
with open("bot_messages/highcouncil_election.txt", mode="r", encoding="utf8") as file:
|
||||||
message = file.read()
|
message = file.read()
|
||||||
|
|
||||||
return message.format()
|
return message.format(
|
||||||
|
clan_council_elect_role_id=self.config.params.clan_council_elect_role_id,
|
||||||
|
highcouncil_election_announce=self.highcouncil_election_announce.strftime("%B %d"),
|
||||||
|
highcouncil_election_start=self.highcouncil_election_start.strftime("%B %d"),
|
||||||
|
highcouncil_election_end=self.highcouncil_election_end.strftime("%B %d"),
|
||||||
|
term_start_date=self.term_start.strftime("%B %d"),
|
||||||
|
)
|
||||||
|
|
||||||
|
def build_highcouncil_vote_start(self) -> str:
|
||||||
|
"""
|
||||||
|
Builds the message to announce that highcouncil voting has started.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
str: Message to send.
|
||||||
|
"""
|
||||||
|
|
||||||
|
with open("bot_messages/highcouncil_vote.txt", mode="r", encoding="utf8") as file:
|
||||||
|
message = file.read()
|
||||||
|
|
||||||
|
return message.format(
|
||||||
|
clan_council_elect_role_id=self.config.params.clan_council_elect_role_id,
|
||||||
|
term_start_date=self.term_start.strftime("%B %d"),
|
||||||
|
)
|
||||||
|
|
||||||
def build_vote_start(self) -> str:
|
def build_vote_start(self) -> str:
|
||||||
"""
|
"""
|
||||||
@@ -117,11 +139,9 @@ class ElectionCycle:
|
|||||||
elif today.date() == self.voting_end.date():
|
elif today.date() == self.voting_end.date():
|
||||||
await self.voting_end_action()
|
await self.voting_end_action()
|
||||||
elif today.date() == self.highcouncil_election_start.date():
|
elif today.date() == self.highcouncil_election_start.date():
|
||||||
await self.highcouncil_election_action()
|
await self.highcouncil_election_start_action()
|
||||||
elif today.date() == self.term_start.date():
|
elif today.date() == self.term_start.date():
|
||||||
await self.term_start_action()
|
await self.term_start_action()
|
||||||
elif today.date() == self.term_end.date():
|
|
||||||
await self.term_end_action()
|
|
||||||
|
|
||||||
async def election_start_action(self) -> None:
|
async def election_start_action(self) -> None:
|
||||||
"""
|
"""
|
||||||
@@ -132,7 +152,7 @@ class ElectionCycle:
|
|||||||
quarter_name: str = self.get_election_cycle_name()
|
quarter_name: str = self.get_election_cycle_name()
|
||||||
|
|
||||||
# create new entry into database.
|
# create new entry into database.
|
||||||
election_channel = await category.create_text_channel(quarter_name)
|
election_channel: nextcord.TextChannel = await category.create_text_channel(quarter_name)
|
||||||
with Session(engine) as session:
|
with Session(engine) as session:
|
||||||
new_cycle = ElectionInformation(ElectionCycle=quarter_name, ElectionChannel=election_channel.id)
|
new_cycle = ElectionInformation(ElectionCycle=quarter_name, ElectionChannel=election_channel.id)
|
||||||
session.add(new_cycle)
|
session.add(new_cycle)
|
||||||
@@ -153,12 +173,7 @@ class ElectionCycle:
|
|||||||
"""
|
"""
|
||||||
message = self.build_vote_start()
|
message = self.build_vote_start()
|
||||||
clan_member_role: nextcord.Role = self.guild.get_role(self.config.params.clan_member_role_id)
|
clan_member_role: nextcord.Role = self.guild.get_role(self.config.params.clan_member_role_id)
|
||||||
with Session(engine) as session:
|
election_channel: nextcord.TextChannel = self.guild.get_channel(self.get_election_info().ElectionChannel)
|
||||||
stmt = select(ElectionInformation).where(
|
|
||||||
ElectionInformation.ElectionCycle == self.get_election_cycle_name()
|
|
||||||
)
|
|
||||||
election_info = session.scalar(stmt)
|
|
||||||
election_channel = self.guild.get_channel(election_info.ElectionChannel)
|
|
||||||
await election_channel.send(message)
|
await election_channel.send(message)
|
||||||
await election_channel.set_permissions(clan_member_role, send_messages=False)
|
await election_channel.set_permissions(clan_member_role, send_messages=False)
|
||||||
|
|
||||||
@@ -166,21 +181,29 @@ class ElectionCycle:
|
|||||||
"""
|
"""
|
||||||
Performs required actions for when voting time has ended.
|
Performs required actions for when voting time has ended.
|
||||||
"""
|
"""
|
||||||
print("voting has ended")
|
message = self.build_highcouncil_election_announce()
|
||||||
|
council_elect_role: nextcord.Role = self.guild.get_role(self.config.params.clan_council_elect_role_id)
|
||||||
|
election_channel: nextcord.TextChannel = self.guild.get_channel(self.get_election_info().ElectionChannel)
|
||||||
|
await election_channel.send(message)
|
||||||
|
await election_channel.set_permissions(council_elect_role, send_messages=True)
|
||||||
|
|
||||||
async def highcouncil_election_action(self) -> None:
|
async def highcouncil_election_start_action(self) -> None:
|
||||||
"""
|
"""
|
||||||
Performs required actions for when the highcouncil is elected.
|
Performs required actions for when the highcouncil is elected.
|
||||||
"""
|
"""
|
||||||
print("Highcouncil election has started.")
|
|
||||||
|
message = self.build_highcouncil_vote_start()
|
||||||
|
election_channel: nextcord.TextChannel = self.guild.get_channel(self.get_election_info().ElectionChannel)
|
||||||
|
await election_channel.send(message)
|
||||||
|
|
||||||
async def term_start_action(self) -> None:
|
async def term_start_action(self) -> None:
|
||||||
msg: str = "the term has started"
|
"""
|
||||||
print(msg)
|
Moves the election channel into the archive category.
|
||||||
|
"""
|
||||||
|
election_channel: nextcord.TextChannel = self.guild.get_channel(self.get_election_info().ElectionChannel)
|
||||||
|
archive: nextcord.CategoryChannel = self.guild.get_channel(self.config.params.archive_channel_group_id)
|
||||||
|
|
||||||
async def term_end_action(self):
|
await election_channel.move(beginning=True, category=archive)
|
||||||
msg: str = "the term has ended"
|
|
||||||
print(msg)
|
|
||||||
|
|
||||||
def get_election_cycle_name(self) -> str:
|
def get_election_cycle_name(self) -> str:
|
||||||
"""
|
"""
|
||||||
@@ -191,3 +214,17 @@ class ElectionCycle:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
return f"{self.election_start.year} {self.elecion_cycle.name} election"
|
return f"{self.election_start.year} {self.elecion_cycle.name} election"
|
||||||
|
|
||||||
|
def get_election_info(self) -> ElectionInformation:
|
||||||
|
"""
|
||||||
|
Gets information for current election.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
ElectionInformation: The information from the database about the current election.
|
||||||
|
"""
|
||||||
|
|
||||||
|
with Session(engine) as session:
|
||||||
|
stmt = select(ElectionInformation).where(
|
||||||
|
ElectionInformation.ElectionCycle == self.get_election_cycle_name()
|
||||||
|
)
|
||||||
|
return session.scalar(stmt)
|
||||||
|
|||||||
Reference in New Issue
Block a user