Modified config and database to use threads.
This commit is contained in:
@@ -185,15 +185,21 @@ class ElectionCycle:
|
|||||||
Performs required actions for when the election cycle starts.
|
Performs required actions for when the election cycle starts.
|
||||||
"""
|
"""
|
||||||
# create new channel for election
|
# 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)
|
quarter_name: str = get_election_cycle_name(self.config)
|
||||||
|
|
||||||
# create new entry into database.
|
# create new entry into database.
|
||||||
|
thread: nextcord.Thread = await parent.create_thread(quarter_name)
|
||||||
clan_member_role: nextcord.Role = self.guild.get_role(
|
clan_member_role: nextcord.Role = self.guild.get_role(
|
||||||
self.config.params.clan_member_role_id
|
self.config.params.clan_member_role_id
|
||||||
)
|
)
|
||||||
|
await thread.set_permissions(clan_member_role, add_reactions=True)
|
||||||
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, ThreadId=thread.id
|
||||||
|
)
|
||||||
session.add(new_cycle)
|
session.add(new_cycle)
|
||||||
session.commit()
|
session.commit()
|
||||||
|
|
||||||
@@ -204,9 +210,9 @@ class ElectionCycle:
|
|||||||
for index, message in enumerate(messages):
|
for index, message in enumerate(messages):
|
||||||
# if last item, add the nominate button
|
# if last item, add the nominate button
|
||||||
if index + 1 == len(messages):
|
if index + 1 == len(messages):
|
||||||
await election_channel.send(message, view=NominateView(self.config))
|
await thread.send(message, view=NominateView(self.config))
|
||||||
else:
|
else:
|
||||||
await election_channel.send(message)
|
await thread.send(message)
|
||||||
|
|
||||||
async def voting_start_action(self) -> None:
|
async def voting_start_action(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class Params:
|
|||||||
general_channel_id: int
|
general_channel_id: int
|
||||||
guild_id: int
|
guild_id: int
|
||||||
high_council_role_id: int
|
high_council_role_id: int
|
||||||
|
voting_parent_id: int
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
@dataclass
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
CREATE TABLE ElectionInformation(
|
CREATE TABLE ElectionInformation(
|
||||||
ElectionCycle varchar(30) not null unique,
|
ElectionCycle varchar(30) not null unique,
|
||||||
ElectionChannel bigint unsigned not null,
|
ThreadId bigint unsigned not null,
|
||||||
CouncilVoteMsgId bigint unsigned,
|
CouncilVoteMsgId bigint unsigned,
|
||||||
PRIMARY KEY (ElectionCycle)
|
PRIMARY KEY (ElectionCycle)
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user