'TypeError: echo() takes 1 positional argument but 2 were given

There is a command in my bot called echo and when I'm trying to call it I get some error. I don't know how to fix it.

@commands.command()
async def echo(ctx, *,args):
    if ctx.author.id in [my id here]:
        await ctx.send(args)
        await ctx.message.delete()
    else:
        await ctx.send("U cant use that :)")

Here is the log:

Private message > !echo now?
Ignoring exception in command echo:
Traceback (most recent call last):
  File "/home/ec2-user/.local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
TypeError: echo() takes 1 positional argument but 2 were given

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ec2-user/.local/lib/python3.7/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/home/ec2-user/.local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/home/ec2-user/.local/lib/python3.7/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: echo() takes 1 positional argument but 2 were given


Solution 1:[1]

use *args instead of *,args. for example:

@commands.command()
async def echo(ctx, *args):
    if ctx.author.id in [my id here]:
        await ctx.send(args)
        await ctx.message.delete()
    else:
        await ctx.send("U cant use that :)")

Solution 2:[2]

Tou should try using “self” due to it being inside a cog (Assuming). And yes, it is ctx, *, args It would look something like this:

@commands.command()
async def echo(self, ctx, *, args):
    if ctx.author.id in [my id here]:
        await ctx.send(args)
        await ctx.message.delete()
    else:
        await ctx.send("You can't use that :)")

By the way, what the code would do is send the message and delete it immediately after, you might want to swap the send and the delete. Let me know if this helped!

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TheAlphaReturns
Solution 2 UnderGame