【发布时间】:2021-04-13 20:51:44
【问题描述】:
我有 3 个嵌入。其中 2 个显示正确的嵌入,但其中一个仅显示空白嵌入。代码几乎相同,所以我不知道出了什么问题。这是我的函数代码:
我的代码:
@client.command()
async def slots(ctx, amount = None):
await open_account(ctx.author)
if amount == None:
await ctx.send("How ya gonna slots 0 coins, dum dum")
return
bal = await update_bank(ctx.author)
amount = int(amount)
if amount>(bal[0]+1):
await ctx.send("You don't even have that many coins, idiot")
return
if amount<0:
await ctx.send("You wanna lose money by gambling negative coins?")
return
final = []
for i in range(3):
a = random.choice([":egg:", ":baby_chick:", ":hatching_chick:",":hatched_chick:",':poultry_leg:',':chicken:'])
final.append(a)
em = Embed(title = f"{ctx.author}s Slots Game", color = discord.Color.lighter_grey())
em.add_field(name = final, value = f"\n{ctx.author}s Slots Game", inline = False)
msg = await ctx.send(embed = em)
if final[0] == final[1] or final[0] == final[2] or final[1] == final[2]:
await update_bank(ctx.author, 2*amount)
em_new = Embed(title = f"{ctx.author}s Slots Game", color = discord.Color.green())
em_new.add_field(name = final, value = f"\n{ctx.author}s Slots Game", inline = False)
em_new.add_field(name = "Win!", value = f"You won {2*amount} coins!")
sleep(1)
await msg.edit(embed=em_new)
if final[0] == final[1] == final[2]:
await update_bank(ctx.author, 3*amount)
em_new = Embed(title = f"{ctx.author}s Slots Game", color = discord.Color.green())
em_new.add_field(name = final, value = f"\n{ctx.author}s Slots Game", inline = False)
em_new.add_field(name = "Win!", value = f"You won {3*amount} coins!")
sleep(1)
await msg.edit(embed=em_new)
else:
await update_bank(ctx.author, -1*amount)
em_new = Embed(title = f"{ctx.author}s Slots Game", color = discord.Color.red())
em_new.add_field(name = final, value = f"\n{ctx.author}s Slots Game", inline = False)
em_new = discord.Embed(name = "Loss!", value = f"You lost {-1*amount} coins.")
sleep(1)
await msg.edit(embed=em_new)
前 2 个 if 语句嵌入工作正常,它们编辑并显示它们应该显示的内容。但是 else 语句嵌入只显示一个空白嵌入。有人可以帮我吗
【问题讨论】:
标签: python discord.py