I have a command:
@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.
I tried:
@bot.command(pass_context=True)
async def hello(ctx):
hellothere(ctx)
But I received an error stating that Command
is not callable.
Does anyone know how to do this?
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)
@client.command(pass_context = True , aliases=['purge', 'clean', 'delete'])
Just change the aliases.
Here's another more "hacky" way (by making two commands using the same function but with different names, this uses the .callback
attribute of Command
):
@bot.command(pass_context=True)
async def hellothere(ctx):
await bot.say("Hello {}".format(ctx.message.author))
bot.command(name="hello", pass_context=True)(hellothere.callback)