Discord.py机器人未正确发送嵌入

时间:2020-04-15 12:47:23

标签: python-3.x discord discord.py

我正在尝试使服务器排在前十名。由于您可以在一个嵌入中添加和发送多少字段似乎受到限制,所以我对记分板进行了划分。但是,我的程序似乎只发送了一个嵌入,如以下image所示。(此图中的if语句为False)

控制台中没有错误消息。

embed = discord.Embed(title = "**Leaderboard**", description = "Top 5")
    embed.set_footer(icon_url = bot.user.avatar_url)

    embed.add_field(name = "Users", value = f"{user1}", inline = True) 
    embed.add_field(name = "Beans", value = f"{bean1}", inline = True)
    embed.add_field(name = "\u200b", value = "\u200b", inline = False)
    embed.add_field(name = "\u200b", value = f"{user2}", inline = True) 
    embed.add_field(name = "\u200b", value = f"{bean2}", inline = True)
    embed.add_field(name = "\u200b", value = "\u200b", inline = False)
    embed.add_field(name = "\u200b", value = f"{user3}", inline = True) 
    embed.add_field(name = "\u200b", value = f"{bean3}", inline = True)
    embed.add_field(name = "\u200b", value = "\u200b", inline = False)
    embed.add_field(name = "\u200b", value = f"{user4}", inline = True)
    embed.add_field(name = "\u200b", value = f"{bean4}", inline = True)
    embed.add_field(name = "\u200b", value = "\u200b", inline = False)
    embed.add_field(name = "\u200b", value = f"{user5}", inline = True) 
    embed.add_field(name = "\u200b", value = f"{bean5}", inline = True)
    embed.add_field(name = "\u200b", value = "\u200b", inline = False)

    await ctx.send(embed = embed)

    embed2 = discord.Embed(title = "**Leaderboard**", description = "Top 10")
    embed.set_footer(icon_url = bot.user.avatar_url)

    embed.add_field(name = "Users", value = f"{user6}", inline = True)
    embed.add_field(name = "Beans", value = f"{bean6}", inline = True)
    embed.add_field(name = "\u200b", value = "\u200b", inline = False)
    embed.add_field(name = "\u200b", value = f"{user7}", inline = True) 
    embed.add_field(name = "\u200b", value = f"{bean7}", inline = True)
    embed.add_field(name = "\u200b", value = "\u200b", inline = False)
    embed.add_field(name = "\u200b", value = f"{user8}", inline = True)
    embed.add_field(name = "\u200b", value = f"{user8}", inline = True)
    embed.add_field(name = "\u200b", value = "\u200b", inline = False)
    embed.add_field(name = "\u200b", value = f"{user9}", inline = True) 
    embed.add_field(name = "\u200b", value = f"{bean9}", inline = True)
    embed.add_field(name = "\u200b", value = "\u200b", inline = False)
    embed.add_field(name = "\u200b", value = f"{user10}", inline = True) 
    embed.add_field(name = "\u200b", value = f"{bean10}", inline = True)
    embed.add_field(name = "\u200b", value = "\u200b", inline = False)

    time.sleep(1)
    await ctx.send(embed = embed2)

    if leaderid not in {user001,user002,user003,user004,user005,user006,user007,user008,user009,user010}:
        embed3 = discord.Embed(title = "**Leaderboard**", description = "Your ranking")
        embed.set_footer(icon_url = bot.user.avatar_url)

        embed.add_field(name = "\u200b", value = f"{user00}", inline = True)
        embed.add_field(name = "\u200b", value = f"{bean00}", inline = True)
        embed.add_field(name = "\u200b", value = "\u200b", inline = False)

        time.sleep(1)
        await ctx.send(embed = embed3)

1 个答案:

答案 0 :(得分:0)

您创建并发送embed2,但只能修改embed。您需要修改embed2

embed2 = discord.Embed(title = "**Leaderboard**", description = "Top 10")
embed2.set_footer(icon_url = bot.user.avatar_url)

embed2.add_field(name = "Users", value = f"{user6}", inline = True)
embed2.add_field(name = "Beans", value = f"{bean6}", inline = True)
...