feat(aurora): add autocomplete to /history's types argument
Some checks failed
Actions / Build Documentation (MkDocs) (pull_request) Successful in 31s
Actions / Lint Code (Ruff & Pylint) (pull_request) Failing after 45s

This commit is contained in:
Seaswimmer 2024-08-13 01:22:18 -04:00
parent 830237938a
commit ad063062fb
Signed by: cswimr
GPG key ID: 3813315477F26F82

View file

@ -11,6 +11,7 @@ import os
import time
from datetime import datetime, timedelta, timezone
from math import ceil
from typing import List
import discord
from class_registry.registry import RegistryKeyError
@ -767,6 +768,21 @@ class Aurora(commands.Cog):
await interaction.followup.send(embed=embed, ephemeral=ephemeral)
@history.autocomplete('types')
async def _history_types(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]:
types: List[str] = sorted(self.type_registry.keys())
choices = list()
if current.endswith(","):
for c in current.split(","):
if c in types:
types.remove(c)
for t in types:
choices.append(app_commands.Choice(name=current+t, value=current+t))
else:
for t in types:
choices.append(app_commands.Choice(name=t, value=t))
return choices[:25]
@app_commands.command(name="resolve")
async def resolve(
self, interaction: discord.Interaction, case: int, reason: str | None = None