Closed rouven0 closed 2 years ago
Thanks for making me aware of this! I'll try to get this implemented by the end of the week.
Your API design looks good, but I might add a few things.
I'd prefer if developers didn't have to touch the options argument (discord.command(options=[...])
) for most use cases. In addition to your suggestion, I might add a Autocomplete
type to be used like
@discord.command()
def city_select(ctx, country: Autocomplete[str], city: Autocomplete[str]):
return f"You selected {country}/{city}"
Since there's (usually) going to be a one-to-one mapping between commands and autocomplete functions, I might also add a convenience decorator along the lines of
...
@city_select.autocomplete()
def city_select_autocomplete(country: Option, city: Option):
...
to help catch typos.
Again, I'll try to get this done by the weekend. Feel free to let me know your thoughts on these ideas in the meantime.
Not long ago discord released autocomplete for slash command options and I'd really appreciate seeing them implemented into this library.
Example use case You have a database with about 1000 different Cities and want the user to select one. With autocomplete you can deliver matches fitting to what the user is typing into that option field.
A Solution I'd like I'd appreciate a decorator based solutions like it's done with the Components. Maybe something like:
Alternatives I've considered There are the default choices but those are limited to 25 per option. Autocomplete allows way more.
Further resources and context https://devsnek.notion.site/devsnek/Application-Command-Option-Autocomplete-Interactions-dacc980320c948768cec5ae3a96a5886
https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-response-object-autocomplete