我正在做一个石头剪刀布命令,我试图保持它的基本性。没有反应,它会检查你的论点,然后机器人会告诉你它选择了什么。代码:
@client.command(aliases=["rockpaperscissors"])
async def rps(ctx, args):
await ctx.message.delete()
if args == ("rock" or "paper" or "scissors" or "Rock" or "Paper" or "Scissors"):
embed=discord.Embed(title='Rock paper scissors', description='You selected ' + args + f' - Bot selected {random.choice(rps)}.', color=RandomColor())
await ctx.send(embed=embed)
else:
await ctx.send("Your option needs to be either rock, paper or scissors.")
所以我想知道我的命令有什么问题。是颜色吗?
答案 0 :(得分:1)
错误在一行:
if args == ("rock" or "paper" or "scissors" or "Rock" or "Paper" or "Scissors"):
右操作数是一个布尔值,所以它永远不会等于一个字符串。应该是
if args in ("rock", "paper", "scissors", "Rock", "Paper", "Scissors"):
甚至
if args.lower() in ("rock", "paper", "scissors"):