【发布时间】:2021-07-25 09:59:30
【问题描述】:
我正在尝试制作一个不和谐的机器人猜谜游戏(使用 python),但它一直失败。我查看了许多类似的帖子,但没有发现任何帮助。
@bot.command(name='play')
async def play(ctx):
number = random.randint(1,100)
await ctx.send('I have a number in mind between 1 and 100, guess')
for i in range(0,5):
guess = await client.wait_for('message') **(see below the code)
if guess.content == number:
await ctx.send('You got it!')
elif guess.content < number:
await ctx.send('Higher!')
elif guess.content > number:
await ctx.send('Lower!')
else:
await ctx.send("You lost, type $play to play again.")
** 通常它会说: , check=check, 但这似乎不起作用,它说,检查未定义或类似的东西
代码似乎卡在:for i in range(0,5):,或:guess = await client.wait_for('message')
有人可以帮忙吗?或者发布一个有效的猜谜游戏+解释?
【问题讨论】:
-
check=check假设您之前已经定义了check。例如,您可以检查消息是否来自作者。
标签: python discord.py