【发布时间】:2021-07-05 20:44:46
【问题描述】:
所以,我正在为 Discord Bot 编写一个 hack 命令(显然是个笑话),但我遇到了一个奇怪的错误。意思是我给出了一个只需要 1 个位置参数的东西,却给出了 2 个参数,即使它显然不是。
@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...")
这是我的错误:
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
我不确定它为什么这么说,正如你所看到的,我确实只给出了一个论点。
如果这有帮助,它会在绑定编辑 from **2/5** | Discord Account password found: `me("+member.name+")iscool"+member.discriminator+" to **3/5** | Logging in to Discord Account...
感谢您的帮助! :D
【问题讨论】:
标签: python python-3.x discord.py