#๐Ÿ”’ Discord Hybrid Command

14 messages ยท Page 1 of 1 (latest)

lapis cliff
#

I would like to make a hybrid command like in the image for verification to have an ephemeral message. I only know how to make basic command, but how do I make this?

summer jewelBOT
#

@lapis cliff

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

eternal harness
#

okay so in the image the name seems to be a non-optional parameter, unlike the 2 others.

@bot.tree.command(
    guild = {your_guid_objet},
    name = "networth",
    description = "...",
)
@app_commands.describe(name = "Minecraft username")
async def my_command(interaction: discord.Interaction, name : str, parameter2 : bool = True, parameter3 : str = 1) :
  # Write your code here

In this code, name is a parameter and you have to fill it in, whereas the other two parameters are optional. If they are not filled in, they are set to their default values.

#

btw, @app_commands.describe(name = "Minecraft username") describes each parameter, for example it could be :

@app_commands.describe(name = "Minecraft username", parameter1 = 'blablabla', parameter2 = '...')
lapis cliff
#

Thank you a lot! I got it with the command, but I'm still a bit confused where the

@bot.tree.command

comes from? I either used a commandTree or just usual like this as example:

tree = app_commands.CommandTree(client)
bot = commands.Bot(command_prefix="/", intents=intents)
blissful otter
#

client?

You should use either discord.Client or commands.Bot, never both
(usually the later)

eternal harness
lapis cliff
blissful otter
#

yeah don't use discord.Client if you are using commands.Bot

commands.Bot is a subclass of discord.Client, it does everything client does and a bit more

eternal harness
#

no pb :)

summer jewelBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.