Add Slash Command Autocomplete #15
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
async def minecraft_username_autocomplete(
interaction: discord.Interaction,
current: str
) -> list[app_commands.Choice[str]]:
"""Suggest previously whitelisted usernames"""
# Could query database of previous usernames
suggestions = ["Steve", "Alex", "Herobrine"] # Example
return [
app_commands.Choice(name=username, value=username)
for username in suggestions if current.lower() in username.lower()
][:25] # Discord limit
@client.tree.command(name="minecraft")
@app_commands.autocomplete(minecraft_username=minecraft_username_autocomplete)
async def minecraft(interaction: discord.Interaction, minecraft_username: str):
# ...existing code...