Thread create ini election start.
build_develop / build (push) Successful in 1m35s

Modified config and database to use threads.
This commit is contained in:
2023-11-07 15:36:33 -05:00
parent ab88652cdb
commit 8d2f2f7dba
3 changed files with 12 additions and 5 deletions
+10 -4
View File
@@ -185,15 +185,21 @@ class ElectionCycle:
Performs required actions for when the election cycle starts.
"""
# create new channel for election
category: nextcord.CategoryChannel = self.guild.get_channel(self.config.params.active_category_id)
parent: nextcord.TextChannel = self.guild.get_channel(
self.config.params.voting_parent_id
)
quarter_name: str = get_election_cycle_name(self.config)
# create new entry into database.
thread: nextcord.Thread = await parent.create_thread(quarter_name)
clan_member_role: nextcord.Role = self.guild.get_role(
self.config.params.clan_member_role_id
)
await thread.set_permissions(clan_member_role, add_reactions=True)
with Session(engine) as session:
new_cycle = ElectionInformation(ElectionCycle=quarter_name, ElectionChannel=election_channel.id)
new_cycle = ElectionInformation(
ElectionCycle=quarter_name, ThreadId=thread.id
)
session.add(new_cycle)
session.commit()
@@ -204,9 +210,9 @@ class ElectionCycle:
for index, message in enumerate(messages):
# if last item, add the nominate button
if index + 1 == len(messages):
await election_channel.send(message, view=NominateView(self.config))
await thread.send(message, view=NominateView(self.config))
else:
await election_channel.send(message)
await thread.send(message)
async def voting_start_action(self) -> None:
"""
+1
View File
@@ -22,6 +22,7 @@ class Params:
general_channel_id: int
guild_id: int
high_council_role_id: int
voting_parent_id: int
@dataclass
+1 -1
View File
@@ -1,6 +1,6 @@
CREATE TABLE ElectionInformation(
ElectionCycle varchar(30) not null unique,
ElectionChannel bigint unsigned not null,
ThreadId bigint unsigned not null,
CouncilVoteMsgId bigint unsigned,
PRIMARY KEY (ElectionCycle)
);