Add command to init.
Correctly set autocomplete. Put newlines where I forgot to.
This commit is contained in:
+15
-7
@@ -26,7 +26,9 @@ class ViewCog(commands.Cog, name="View Commands"):
|
||||
Parent slash command for set. Never called.
|
||||
"""
|
||||
|
||||
@view.subcommand(description="Shows all voters and who they voted for in a given election.")
|
||||
@view.subcommand(
|
||||
description="Shows all voters and who they voted for in a given election."
|
||||
)
|
||||
async def votes(
|
||||
self,
|
||||
interaction: nextcord.Interaction,
|
||||
@@ -53,17 +55,21 @@ class ViewCog(commands.Cog, name="View Commands"):
|
||||
|
||||
for vote in votes:
|
||||
content += (
|
||||
f"<@{vote.VoterId}> voted for <@{vote.VotedForId}>."
|
||||
f"<@{vote.VoterId}> voted for <@{vote.VotedForId}>.\n"
|
||||
if vote.VotedForId is not None
|
||||
else f"<@{vote.VoterId}> abstained from voted."
|
||||
else f"<@{vote.VoterId}> abstained from voted.\n"
|
||||
)
|
||||
|
||||
await interaction.response.send_message(content=content, ephemeral=True)
|
||||
except:
|
||||
await interaction.response.send_message(f"Invalid election: {election_name}.", ephemeral=True)
|
||||
await interaction.response.send_message(
|
||||
f"Invalid election: {election_name}.", ephemeral=True
|
||||
)
|
||||
|
||||
@view.on_autocomplete("election_name")
|
||||
async def election_autocomplete(self, interaction: nextcord.Interaction, election_name: str):
|
||||
@votes.on_autocomplete("election_name")
|
||||
async def election_autocomplete(
|
||||
self, interaction: nextcord.Interaction, election_name: str
|
||||
):
|
||||
"""
|
||||
Collects all elections that start with the election string.
|
||||
|
||||
@@ -82,6 +88,8 @@ class ViewCog(commands.Cog, name="View Commands"):
|
||||
return
|
||||
|
||||
autofilled_elections: "list[str]" = [
|
||||
election for election in elections if election.lower().startswith(election_name.lower())
|
||||
election
|
||||
for election in elections
|
||||
if election.lower().startswith(election_name.lower())
|
||||
]
|
||||
await interaction.response.send_autocomplete(autofilled_elections[:25])
|
||||
|
||||
Reference in New Issue
Block a user