Discord.py 锁定

Discord.py lock

我正在尝试制作一个有趣的小游戏,用户可以在其中尝试破解机器人代码以获得 VRchat 世界的访问代码,这是目前为止的代码。

@client.command()
async def test(ctx):
  await ctx.send('```-------------\n|[1] [2] [3]|\n|[4] [5] [6]|\n|[7] [8] [9]|\n|    [0]    |\n-------------```')
  try:
    async def check(m):
      return ctx.author == m.author 
      Q = await client.wait_for('message', timeout=60.0, check=check)
      if Q.content.lower() == "6842":
        await ctx.send("Yay! you got it. The code for the VRchat secrect room is ****")
      else: 
        await ctx.send("Wrong try again\n```-------------\n|[1] [2] [3]|\n|[4] [5] [6]|\n|[7] [8] [9]|\n|    [0]    |\n-------------```")
  except:
    pass

它不会发送消息,也不会接受输入。

做了一些研究,我发现我做的是正确的,但我只需要用我的大脑来弄清楚它,也就是 youtube,再加上一些我从 python[=11= 工作中知道的东西]

@client.command()
async def test(ctx):
  await ctx.send('```-------------\n|[1] [2] [3]|\n|[4] [5] [6]|\n|[7] [8] [9]|\n|    [0]    |\n-------------```')
  while True:
    def check(m):
      return ctx.author == m.author and ctx.channel == m.channel
    message = await client.wait_for('message', check=check)
    if message.content.lower() == "7592":
      await ctx.send("Yay! you got it. The code for the VRchat secrect room is ```8451```")
      break
    else: 
      await ctx.send("Wrong try again\n```-------------\n|[1] [2] [3]|\n|[4] [5] [6]|\n|[7] [8] [9]|\n|    [0]    |\n-------------```")