-1

So, I'm writing a hack command for a Discord Bot (obviously a joke) and I'm getting a weird error. It's saying I've given something that only takes 1 positional argument was given 2 arguments, even though it clearly was not.

@client.command()
async def hack(message, member:discord.Member):
  message = await message.reply("**It's info yoinking time!**\nHacking "+member.name+"\n\n**This command is currently only proof-of-concept and does not work past finding password. Slend is working on a fix.**")

  await asyncio.sleep(3)

  await message.edit(content="**1/5** | Finding e-mail address...")

  await asyncio.sleep(3)

  await message.edit(content="**1/5** | E-mail address found: `"+member.name+"@discord.com`")

  await asyncio.sleep(2)

  await message.edit(content="**2/5** | Finding password to Discord Account...")

  await asyncio.sleep(3)

  await message.edit(content="**2/5** | Discord Account password found: `me("+member.name+")iscool"+member.discriminator+"`")

  await asyncio.sleep(2)

  await message.edit("**3/5** | Logging in to Discord Account...")

And this is my error:

Ignoring exception in command hack:
Traceback (most recent call last):
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "main.py", line 107, in hack
    await message.edit("**3/5** | Logging in to Discord Account...")
TypeError: edit() 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 "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/opt/virtualenvs/python3/lib/python3.8/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: edit() takes 1 positional argument but 2 were given

I'm not sure why it's saying that, as you can see I've indeed only given it one argument. If this helps, it throws this error when tying to edit from **2/5** | Discord Account password found: `me("+member.name+")iscool"+member.discriminator+" to **3/5** | Logging in to Discord Account...

Thanks for any help! :D

  • Does this answer your question? [TypeError: method() takes 1 positional argument but 2 were given](https://stackoverflow.com/questions/23944657/typeerror-method-takes-1-positional-argument-but-2-were-given) – mx0 Jul 05 '21 at 21:40

1 Answers1

0

Your last line is wrong, content is a keyword-only argument

await message.edit(content="**3/5** | Logging in to Discord Account...")

I'm unsure why you did it wrong that last time, the attempts before were done right.

Łukasz Kwieciński
  • 14,992
  • 4
  • 21
  • 39
  • I'm not too sure what was different there, but using the fact you said "*Your last line is wrong*", I just copied one of the previous lines and changed what was said. For that reason you get that tick. – Slender the Blender Jul 05 '21 at 21:03
  • You passed the string as a positional argument, `message.edit` only takes keyword arguments. – Łukasz Kwieciński Jul 05 '21 at 21:11