X
X
xis22482020-07-13 04:25:54
Python
xis2248, 2020-07-13 04:25:54

How to make "separate commands" in discord.py?

I need async def help islam(ctx): instead
of async def help_islam(ctx):
i.e. separately

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Nevzorov, 2020-07-13
@xis2248

For normal "nested" commands, use command groups
. However, in the situation described in your question, this will not help.
In your situation, I see two options:
1. Refuse the built-in help command and create your own, with a command group method

bot.remove_command("help")

@bot.group(invoke_without_command=True)
async def help(ctx, ...):
    ...  # вручную построенная/собирающая команда help.

@help.command()
async def islam(ctx, ...):
    ...  # подкоманда help

2. Just use docstring in the command method to display the required information
@bot.command()
async def islam(ctx):
    """Описание команды"""
    ...

2.1 You can also use decorator arguments:
@bot.command(
    help="Данный текст будет использоваться в полноразмерной помощи (help islam)", 
    brief="Данный текст будет отображаться в help рядом с командой", 
    usage="Данный текст будет отображаться вместо автоматического построенного текста для аргументов (таких как <arg> [arg] и т.д.)"
)
async def islam(ctx):
    ...

R
Renat Ataev, 2020-07-13
@fanepka

You are not in a hurry to develop bots. The fact that you watched the video on how to make a bot will not give you knowledge in Python. Learn Python first, and then you won't ask stupid questions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question