mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-04-20 16:00:29 +00:00
Add an example for app_commands.rename()
Co-authored-by: Danny <Rapptz@users.noreply.github.com>
This commit is contained in:
parent
61105ce925
commit
8e9e25246e
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user