diff --git a/cogs/commands/__init__.py b/cogs/commands/__init__.py index 7232b00..f161699 100644 --- a/cogs/commands/__init__.py +++ b/cogs/commands/__init__.py @@ -7,6 +7,7 @@ from nextcord.ext import commands from cogs.commands.request import RequestCog from cogs.commands.set import setCog from cogs.commands.test import TestCog +from cogs.commands.view import ViewCog # This function will be called when this extension is loaded. @@ -19,3 +20,4 @@ def setup(bot: commands.Bot): bot.add_cog(RequestCog(bot)) bot.add_cog(TestCog(bot)) bot.add_cog(setCog()) + bot.add_cog(ViewCog()) diff --git a/cogs/commands/view.py b/cogs/commands/view.py index c20fdb8..7d6f7ef 100644 --- a/cogs/commands/view.py +++ b/cogs/commands/view.py @@ -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])