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?
>Solution :
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.