Made function to gather and send the council members message in the clan info channel.
This commit is contained in:
@@ -23,7 +23,9 @@ from database_setup.sql_data_classes import (
|
||||
from utils import (
|
||||
build_highcouncil_votes_str,
|
||||
build_votes_str,
|
||||
edit_clan_message,
|
||||
get_cl_election_name,
|
||||
get_cycle_name,
|
||||
get_datetime,
|
||||
get_dm_election_name,
|
||||
get_election_cycle_name,
|
||||
@@ -437,6 +439,7 @@ class ElectionCycle:
|
||||
)
|
||||
|
||||
await election_thread.edit(archived=True, locked=True)
|
||||
await self.edit_clan_council_message()
|
||||
|
||||
def get_election_info(self) -> ElectionInformation:
|
||||
"""
|
||||
@@ -466,3 +469,53 @@ class ElectionCycle:
|
||||
message += f"to <#{self.get_election_info().ThreadId}> to cast your vote!"
|
||||
|
||||
await general.send(content=message)
|
||||
|
||||
async def edit_clan_council_message(self):
|
||||
clan_info_channel: nextcord.TextChannel = await self.guild.fetch_channel(
|
||||
self.config.params.clan_info_channel_id
|
||||
)
|
||||
|
||||
election = get_election_cycle_name(self.config)
|
||||
with Session(engine) as session:
|
||||
stmt = (
|
||||
select(CouncilMembers.MemberId)
|
||||
.where(CouncilMembers.ElectionCycle == election)
|
||||
.where(CouncilMembers.DiscordManager == true())
|
||||
)
|
||||
discord_manager = session.scalar(stmt)
|
||||
stmt = (
|
||||
select(CouncilMembers.MemberId)
|
||||
.where(CouncilMembers.ElectionCycle == election)
|
||||
.where(CouncilMembers.ClanLeader == true())
|
||||
)
|
||||
clan_leader = session.scalar(stmt)
|
||||
stmt = (
|
||||
select(CouncilMembers.MemberId)
|
||||
.where(CouncilMembers.ElectionCycle == election)
|
||||
.where(CouncilMembers.Elected == true())
|
||||
)
|
||||
|
||||
council_members_strs = [
|
||||
f"<@{id}>"
|
||||
for id in session.scalars(stmt)
|
||||
if id not in (discord_manager, clan_leader)
|
||||
]
|
||||
|
||||
quarter = get_cycle_name(self.config)
|
||||
high_council_str = (
|
||||
f"Discord manager: <@{discord_manager}>\nClan Leader: <@{clan_leader}>"
|
||||
)
|
||||
|
||||
with open(
|
||||
"bot_messages/council_members.txt", mode="r", encoding="utf8"
|
||||
) as file:
|
||||
message = file.read()
|
||||
message.format(
|
||||
quarter=quarter,
|
||||
council="\n".join(council_members_strs),
|
||||
high_council=high_council_str,
|
||||
)
|
||||
|
||||
await edit_clan_message(
|
||||
session, clan_info_channel, "council_members.txt", message
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user