我在做什么:我试图在discord.py中制作一个typeracer,但首先我试图用def check
和def inner_check
来绕圈子
问题:如下图所示,当我输入正确的句子时,它仍然告诉我我错了。据我检查,没有错误。我使用了来自this link here,的代码,这有助于作者的输入,以防有帮助
代码:
@client.command()
async def tr(ctx):
starttime = time.time()
C = "Just a nice little test"
await ctx.send(f"Type: {C}")
a = 1
def check(author):
def inner_check(message):
return message.author == author and message.content == C
return inner_check
while a == 1:
msg = await client.wait_for('message', check=check(ctx.author))
if msg == True:
a = a - 1
else:
await ctx.send("wrong")
fintime = time.time()
total = fintime - starttime
await ctx.send(round(total,2),"seconds")
基本上,他们的Github示例只是做了一些调整
基于Doyousketch2的回答,我已经用
@client.command
编写了另一种方法,因为它需要更多的调整。我还包括了所用的时间(四舍五入到最接近的整秒)发生了什么变化:
@client.command
而不是“if message.content==”!类型'message.channel.send
现在{message.author
更改为ctx.author
,因为message
将给出一个错误name 'message' is not defined
相关问题 更多 >
编程相关推荐