diff --git a/examples/app_commands/basic.py b/examples/app_commands/basic.py index 6896f28e1..51a41b0a8 100644 --- a/examples/app_commands/basic.py +++ b/examples/app_commands/basic.py @@ -57,6 +57,17 @@ async def add(interaction: discord.Interaction, first_value: int, second_value: await interaction.response.send_message(f'{first_value} + {second_value} = {first_value + second_value}') +# The rename decorator allows us to change the display of the parameter on Discord. +# In this example, even though we use `text_to_send` in the code, the client will use `text` instead. +# Note that other decorators will still refer to it as `text_to_send` in the code. +@client.tree.command() +@app_commands.rename(text_to_send='text') +@app_commands.describe(text_to_send='Text to send in the current channel') +async def send(interaction: discord.Interaction, text_to_send: str): + """Sends the text into the current channel.""" + await interaction.response.send_message(text_to_send) + + # To make an argument optional, you can either give it a supported default argument # or you can mark it as Optional from the typing standard library. This example does both. @client.tree.command()