Narmy
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
11 additions and
0 deletions
-
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() |
|
|
|