【发布时间】:2021-01-31 05:37:34
【问题描述】:
我正在尝试使用 discord.py 创建警告命令。但是出于证明和原因,我在字符串参数方面遇到了麻烦。我试过用谷歌搜索这个问题,但找不到解决方案,比如使用 .format 或 .startswith。有没有人可以解决这个问题?
错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: warn() missing 1 required keyword-only argument: 'proof'
使用的代码:
async def warn(context,member: discord.Member,*,reason:str,proof:str):
tests = collection.find({"name":"test"})
for test in tests:
extract = (test["id"])
extract += 1
collection.update_one(update={"$set": {"id":extract}},filter={})
print(extract)
print(member.name)
warnings = {"id": extract, "member": member.name, "reason": reason, "type": "warn", "proof":proof}
collection.insert_one(warnings)
await context.send(f"Succesfully warned {member.name} for {reason}")
await member.send(f"You were warned in Mega Studios for {reason}")```
【问题讨论】:
标签: python parameters discord discord.py discord.py-rewrite