Add highcouncil winners message.

This commit is contained in:
2023-12-17 12:33:05 -05:00
parent a1896416fc
commit 18d433ce8c
+22 -1
View File
@@ -20,7 +20,13 @@ from database_setup.sql_data_classes import (
Votes, Votes,
engine, engine,
) )
from utils import build_votes_str, get_datetime, get_election_cycle_name from utils import (
build_votes_str,
get_cl_election_name,
get_datetime,
get_dm_election_name,
get_election_cycle_name,
)
class ElectionCycle: class ElectionCycle:
@@ -346,10 +352,25 @@ class ElectionCycle:
reason=f"{member.display_name} has been elected to council.", reason=f"{member.display_name} has been elected to council.",
) )
# announce high council members
dm_election = get_dm_election_name(self.config)
cl_election = get_cl_election_name(self.config)
stmt = select(Votes.VotedForId).where(Votes.ElectionCycle == dm_election)
dm_votes = collections.Counter(session.scalars(stmt))
stmt = select(Votes.VotedForId).where(Votes.ElectionCycle == cl_election)
cl_votes = collections.Counter(session.scalars(stmt))
dm_winner = max(dm_votes, key=dm_votes.get)
cl_winner = max(cl_votes, key=cl_votes.get)
election_thread: nextcord.Thread = self.guild.get_thread( election_thread: nextcord.Thread = self.guild.get_thread(
self.get_election_info().ThreadId self.get_election_info().ThreadId
) )
highcouncil_msg: str = f"Congratulations for our high council members!\n Clan Leader: <@{cl_winner}>\n"
highcouncil_msg += f"Discord Manager: <@{dm_winner}>"
await election_thread.send(highcouncil_msg)
await election_thread.send( await election_thread.send(
"This election cycle is now over. Thank you everyone for participating!" "This election cycle is now over. Thank you everyone for participating!"
) )