如何给命令多个名称? [英] How to give a command multiple names?

查看:88
本文介绍了如何给命令多个名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一条命令:

@bot.command(pass_context=True)
async def hellothere(ctx):
   await Bot.say("Hello {}".format(ctx.message.author))

我想复制此命令的副本。

I want to make a copy of this command that is shorter.

我尝试过:

@bot.command(pass_context=True)
async def hello(ctx):
   hellothere(ctx)

但是我收到一条错误消息,指出 Command 无法调用。

But I received an error stating that Command is not callable.

有人知道怎么做吗?

推荐答案

您应该可以使用 Command.invoke 协程。

You should be able to use the Command.invoke coroutine. Something like

@bot.command(pass_context=True)
async def hello(ctx):
    await hellothere.invoke(ctx)

这篇关于如何给命令多个名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆