Discord.py 1.7 随机选择不起作用

Discord.py 1.7 random choice is not working

我在 Discord.py 1.7 上编写轮盘赌命令,我让它选择一个数字,然后查看数字是偶数还是奇数。如果我在执行命令时选择偶数,并且代码选择的数字是偶数,它会发送一条获胜消息。当它们都是奇数时也是如此。当我选择偶数而代码选择奇数时出现问题。发生这种情况时,它仍会显示获胜消息。我更加困惑,因为当我选择奇数而代码选择偶数时,它会显示丢失消息。这是我的代码

choices = ['odd','even']
@slash.slash(description='A staple of gambling')
async def roulette(ctx,bet:int,choice):
  if choice == int:
    await ctx.send('Sorry, you cannot bet on singular numbers yet. this will be added soon')
  elif any(word in choice for word in choices):
    q = await ctx.send('Bets are in place!\nresults revealed in: 3 seconds')
    await asyncio.sleep(1)
    await q.edit(content='Bets are in place!\nresults revealed in: 2 seconds')
    await asyncio.sleep(1)
    await q.edit(content='Bets are in place!\nresults revealed in: 1 second')
    await asyncio.sleep(1)
    e = random.randint(0,36)
    if e == 0 or 2 or 4 or 6 or 8 or 10 or 12 or 14 or 16 or 18 or 20 or 22 or 24 or 26 or 28 or 30 or 32 or 34 or 36:
      if choice == 'even':
        win = int(bet) * 2
        await q.edit(content=f'Number:{e}\nYou win {ctx.author.mention}!!!\n\nYou bet {bet}, and win double your money!!!\n{win}')
      if choice == 'odd':
        await q.edit(content=f'Number:{e}\nSorry {ctx.author.mention}, you lost your bet!')
    elif e == 1 or 3 or 5 or 7 or 9 or 11 or 13 or 15  or 17 or 19 or 21 or 23 or 25 or 27 or 29 or 31 or 33 or 35:
      if choice == 'odd':
        win = int(bet) * 2
        await q.edit(content=f'Number:{e}\nYou win {ctx.author.mention}!!!\n\nYou bet {bet}, and win double your money!!!\n{win}')
      if choice == 'even':
        await q.edit(content=f'Number:{e}\nSorry {ctx.author.mention}, you lost your bet!')
  else:
    await ctx.send(f'sorry {ctx.author.mention}, that is not a valid choice. Valid choices: {choices}')

我发现这可能是因为用户输入可能是 Odd 而不是 odd。我这样做是为了将输入转换为小写。

我不知道你为什么列出每个偶数和奇数,所以程序现在检测用户输入的数字是偶数还是奇数,以及它是否小于 37(或奇数 36)有效。

choices = ['odd','even']
@slash.slash(description='A staple of gambling')
async def roulette(ctx,bet:int,choice):
  if choice == int:
    await ctx.send('Sorry, you cannot bet on singular numbers yet. this will be added soon')
  elif any(word in choice for word in choices):
    q = await ctx.send('Bets are in place!\nresults revealed in: 3 seconds')
    await asyncio.sleep(1)
    await q.edit(content='Bets are in place!\nresults revealed in: 2 seconds')
    await asyncio.sleep(1)
    await q.edit(content='Bets are in place!\nresults revealed in: 1 second')
    await asyncio.sleep(1)
    e = random.randint(0,36)
    if (e % 2) == 0: # e is even
      if choice.lower() == 'even': # add choice.lower() to make sure that caps lock doesn't break the program.
        win = int(bet) * 2
        await q.edit(content=f'Number:{e}\nYou win {ctx.author.mention}!!!\n\nYou bet {bet}, and win double your money!!!\n{win}')
      if choice.lower() == 'odd': # add choice.lower() to make sure that caps lock doesn't break the program.
        await q.edit(content=f'Number:{e}\nSorry {ctx.author.mention}, you lost your bet!')
    elif (e % 2) != 0: # e is not even
      if choice.lower() == 'odd': # add choice.lower() to make sure that caps lock doesn't break the program.
        win = int(bet) * 2
        await q.edit(content=f'Number:{e}\nYou win {ctx.author.mention}!!!\n\nYou bet {bet}, and win double your money!!!\n{win}')
      if choice.lower() == 'even': # add choice.lower() to make sure that caps lock doesn't break the program.
        await q.edit(content=f'Number:{e}\nSorry {ctx.author.mention}, you lost your bet!')
  else:
    await ctx.send(f'sorry {ctx.author.mention}, that is not a valid choice. Valid choices: {choices}')