Skip to content

app_commands options #9495

Answered by LostLuma
thejammyproject asked this question in Q&A
Jul 13, 2023 · 1 comments · 1 reply
Discussion options

You must be logged in to vote

App commands in discord.py specify their parameters via Python parameters rather than having to manually specify them in the decorator. The different types of options can be used by placing their respective type into the type hint for the parameter. See two short examples here:

# Turns into a command called /example_one with a required string as an option
@client.tree.command()
async def example_one(interaction: discord.Interaction, example: str) -> None:
    ...

# Turns into a command called /example_two which requires choosing a server member to use
@client.tree.command()
async def example_two(interaction: discord.Interaction, example: discord.Member) -> None:
    ...

See more examples…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@thejammyproject
Comment options

Answer selected by thejammyproject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants