#๐ Discord Hybrid Command
14 messages ยท Page 1 of 1 (latest)
@lapis cliff
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.
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 = '...')
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)
client?
You should use either discord.Client or commands.Bot, never both
(usually the later)
okay, i have this in my code :
server_obj = discord.Object(id=server)
intents = discord.Intents().all()
intents.message_content = True
intents.guilds = True
intents.members = True
bot = commands.Bot(command_prefix="!", intents=intents)
but idk if this is really useful lol, especially command_prefix and all the thingd with 'intents' like intents.guild etc
Client is defined as discord.Client and as I said I either use one of those.
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
good to know that ty!
alright thx for the help
no pb :)
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.