我需要有关 Discord.py 的帮助
我尝试创建一个猜谜游戏。机器人会创建一个 1 到 20(包括 20)之间的随机数,然后您尝试在 6 次或少于 6 次的时间内猜测它。当您发送号码时,它会告诉您该号码是否太高/太低。
这是我的代码:
@client.command()
async def guessnumber(ctx):
user = ctx.author
await ctx.send(f"Hello {user}! I'm thinking of a number between 1 and 20. You are given 6 tries to find the number. Good luck!")
secretNumber = random.randint(1,20)
for guessesTaken in range(1,7):
guess = int(input())
if guess < secretNumber:
await ctx.send("Your guess is too low")
elif guess > secretNumber:
await ctx.send("Your guess is too high")
else:
break
if guess == secretNumber:
await ctx.send(f"GG! You correctly guessed the number!")
else:
await ctx.send(f"Nope, sorry, you took to many guesses. The number I was thinking of was {secretNumber}")
但是,当我发送命令时,它会发送开头部分,但是当我发送数字时,它不会响应。
慕哥9229398
相关分类