Здравствуйте, я пытаюсь добавить {0.subcommand_passed}
в await bot.send_message
, но я получаю сообщение об ошибке, так как добавить, чтобы поймать неправильную команду, переданную в ответ.
Так что если члены набирают ?helol
вместо ?hello
, бот должен ответить helol is a wrong command
@bot.event
async def on_command_error(error, ctx):
if isinstance(error, commands.CommandNotFound):
await bot.send_message(ctx.message.channel, "**Wrong command ** " + ctx.invoked_with)
и в подкоманде, если члены набирают ?cool girl
вместо ?cool boy
, бот должен ответить girl is a wrong sub command
@bot.group(pass_context=True)
async def cool(ctx):
if ctx.invoked_subcommand is None:
if ctx.subcommand_passed:
await bot.say("**Wrong sub command: **{}".format(ctx.subcommand_passed))
else:
await bot.say("**Subcommand required**. {0.author.mention}".format(ctx.message))
@cool.command(pass_context=True)
async def boy(ctx):
msg = "Hello ...".format(ctx.message)
await bot.say(msg)