Pass VoteType str instead of manual one in VoteSelect.
build_develop / build (push) Successful in 1m24s
build_develop / build (push) Successful in 1m24s
This commit is contained in:
@@ -435,7 +435,7 @@ class ElectionCycle:
|
||||
await vote_msg.edit(view=None)
|
||||
|
||||
highcouncil_msg: str = (
|
||||
f"Congratulations for our high council members!\n Clan Leader: <@{cl_winner}>\n"
|
||||
f"Congratulations for our high council members!\nClan Leader: <@{cl_winner}>\n"
|
||||
)
|
||||
highcouncil_msg += f"Discord Manager: <@{dm_winner}>"
|
||||
await election_thread.send(highcouncil_msg)
|
||||
|
||||
@@ -34,16 +34,6 @@ class VoteSelect(nextcord.ui.StringSelect):
|
||||
self.election_type = election_type
|
||||
|
||||
async def callback(self, interaction: Interaction):
|
||||
# decide on election type
|
||||
match self.election_type:
|
||||
case "cl":
|
||||
election_type: str = VoteType.CLANLEADER
|
||||
case "dm":
|
||||
election_type: str = VoteType.DISCORDMANAGER
|
||||
case _:
|
||||
# should never happen
|
||||
raise ValueError('election type was not "cl" or "dm"')
|
||||
|
||||
election_name: str = get_election_name(self.config)
|
||||
with Session(engine) as session:
|
||||
stmt = select(ElectionInformation.HighCouncilVoteMsgId).where(
|
||||
@@ -60,7 +50,7 @@ class VoteSelect(nextcord.ui.StringSelect):
|
||||
ElectionCycle=election_name,
|
||||
VoterId=interaction.user.id,
|
||||
VotedForId=voted_for,
|
||||
Type=election_type,
|
||||
Type=self.election_type,
|
||||
)
|
||||
|
||||
try:
|
||||
@@ -74,7 +64,7 @@ class VoteSelect(nextcord.ui.StringSelect):
|
||||
update(Votes)
|
||||
.where(Votes.ElectionCycle == election_name)
|
||||
.where(Votes.VoterId == interaction.user.id)
|
||||
.where(Votes.Type == election_type)
|
||||
.where(Votes.Type == self.election_type)
|
||||
.values(VotedForId=voted_for)
|
||||
)
|
||||
session.execute(stmt)
|
||||
@@ -173,7 +163,9 @@ class VoteHighcouncilView(nextcord.ui.View):
|
||||
|
||||
view = nextcord.ui.View()
|
||||
view.add_item(
|
||||
VoteSelect(options=options, config=self.config, election_type="cl")
|
||||
VoteSelect(
|
||||
options=options, config=self.config, election_type=VoteType.CLANLEADER
|
||||
)
|
||||
)
|
||||
|
||||
await interaction.response.send_message(
|
||||
@@ -251,7 +243,11 @@ class VoteHighcouncilView(nextcord.ui.View):
|
||||
|
||||
view = nextcord.ui.View()
|
||||
view.add_item(
|
||||
VoteSelect(options=options, config=self.config, election_type="dm")
|
||||
VoteSelect(
|
||||
options=options,
|
||||
config=self.config,
|
||||
election_type=VoteType.DISCORDMANAGER,
|
||||
)
|
||||
)
|
||||
|
||||
await interaction.response.send_message(
|
||||
|
||||
Reference in New Issue
Block a user