diff --git a/cogs/commands/view.py b/cogs/commands/view.py index a1ea1b1..872c1e8 100644 --- a/cogs/commands/view.py +++ b/cogs/commands/view.py @@ -187,3 +187,31 @@ class ViewCog(commands.Cog, name="View Commands"): if election.lower().startswith(election_name.lower()) ] await interaction.response.send_autocomplete(autofilled_elections[:25]) + + @event_points.on_autocomplete("quarter_name") + async def event_points_autocomplete( + self, interaction: nextcord.Interaction, quarter_name: str + ): + """ + Collects all elections that start with the election string. + + Args: + interaction (nextcord.Interaction): Interaction with command. + quarter_name (str): String to run autocomplete on. + """ + + with Session(engine) as session: + stmt = select(ParticipationPoints.Cycle).distinct() + quarters = session.scalars(stmt) + + # if empty compare string + if not quarter_name: + await interaction.response.send_autocomplete(list(quarters)[:25]) + return + + autofilled_quarters: "list[str]" = [ + quarter + for quarter in quarters + if quarter.lower().startswith(quarter_name.lower()) + ] + await interaction.response.send_autocomplete(autofilled_quarters[:25])