Подкоманды в Python Bot - PullRequest
0 голосов
/ 27 мая 2018

Как создавать подкоманды в боте Python.

   @bot.group(pass_context=True)
        async def First(ctx):
            if ctx.invoked_subcommand is None:
                await bot.say('Invalid sub command passed...')

        @First.command(pass_context=True)
        async def Second(ctx):
            msg = 'Finally got success {0.author.mention}'.format(ctx.message)
            await bot.say(msg)

1 Ответ

0 голосов
/ 27 мая 2018

Вам нужно также сделать Second группой.

@bot.group(pass_context=True)
async def First(ctx):
    if ctx.invoked_subcommand is None:
        await bot.say('Invalid sub command passed...')

@First.group(pass_context=True)
async def Second(ctx):
    if ctx.invoked_subcommand is Second:
        await bot.say('Invalid sub command passed...')

@Second.command(pass_context=True)
async def Third(ctx):
    msg = 'Finally got success {0.author.mention}'.format(ctx.message)
    await bot.say(msg)
...