Reputation:
I am trying to make a discord bot but when I try to add another command the second command isn't recognised. here is the relevant code:
@bot.command()
async def parrot(ctx, *, arg):
await ctx.channel.send(arg)
async def talkparrot(ctx, *, arg):
await ctx.channel.send(arg, tts=True)
When I type ".parrot arg1" it works fine but ".taklparrot arg1" doesn't work. Why is this?
Upvotes: 0
Views: 188
Reputation: 911
You need to apply the decorator multiple times:
@bot.command()
async def parrot(ctx, *, arg):
await ctx.channel.send(arg)
@bot.command()
async def talkparrot(ctx, *, arg):
await ctx.channel.send(arg, tts=True)
Now the bot.command()
decorator will be applied to both functions. You can apply the decorator for as many commands as you need. Do not apply this decorator to every function, though, only commands.
Upvotes: 2
Reputation: 1925
In order to make commands you can add the shortcut decorator to a function and it will convert that function into a command.
This is also repeatable so you don't have to do it for just one command, it will do it for every function you want.
Upvotes: 1