我一直在尝试为客户编写一个机器人程序,但由于我自学成才,有时最简单的方面我就不知道了。我知道我以前知道如何执行此操作,但我需要修复以下代码:
@client.command()
async def rroulette(ctx):
await ctx.send(f"Aye, {ctx.author.mention}! Choose a number beween **1** and **6**! We all know what happens if your number is chosen, though, Comrade! ;)")
rroulette1 = await client.wait_for("Message")
await ctx.send("Alright, Comrade! Here goes nothing!")
await asyncio.sleep(2)
rroulette2 = (random.randint(1, 6))
if rroulette2 == rroulette1.content:
await ctx.send("Oops! The number was " + rroulette1.content + "! You know what that means!")
else:
await ctx.send("Ah, you are safe, Comrade! The number was not yours.")
bot总是使用else
函数响应,即您的号码从未被选中。我不知道如何解决这个问题
正如您可能猜到的,代码的总体目的是玩俄罗斯轮盘赌。如果选择了您的号码,您将被静音5分钟。任何帮助都将不胜感激
正如@Oli所说,
rroulette1
的内容始终是一个字符串,您需要将其转换为int
,这应该可以工作相关问题 更多 >
编程相关推荐