Python 3.x 同一嵌入| Discord.py中的多个结果

Python 3.x 同一嵌入| Discord.py中的多个结果,python-3.x,discord.py,Python 3.x,Discord.py,如何在同一个嵌入中包含多个结果 这是代码顺便说一句 @client.command() async def list(ctx): role = discord.utils.get(ctx.guild.roles, name="mute") for member in ctx.guild.members: if role in member.roles: embed = discord.Embed(title="Mute members")

如何在同一个嵌入中包含多个结果

这是代码顺便说一句

@client.command()
async def list(ctx):
    role = discord.utils.get(ctx.guild.roles, name="mute")
    for member in ctx.guild.members:
        if role in member.roles:
            embed = discord.Embed(title="Mute members")
            embed.add_field(name="Name", value=f"**{member.name}**",inline=False)
            embed.add_field(name="ID", value=f"{member.id}",inline=True)
            await ctx.send(embed=embed)
            empty = False
    if empty:
        await ctx.send("Nobody has the role {}".format(role.mention))

现在的情况是。当有多个静音成员时,bot会发送不同的嵌入。我希望所有结果都在同一个嵌入中

下面是一个使用大量列表理解的示例:

@client.command()
异步定义列表(ctx):
role=discord.utils.get(ctx.guild.roles,name=“mute”)
mute=[(m.name,m.id)表示ctx.guild.members中的m,如果[r.name表示m.roles中的r为“mute”]
如果len(静音)>0:
嵌入=discord.embed(title=“静音成员”)
embed.add_字段(name=“Names”,value=f“**{,”.join([i[0]表示处于静音状态的i])}**,inline=False)
embed.add_字段(name=“ID”,value=f“{”,”.join([str(i[1]),用于静音中的i]),inline=True)
等待ctx.send(嵌入=嵌入)
其他:
等待ctx.send(f“没有人拥有角色{role.ention}”)
它生成一个元组列表,格式为:
[(“名称”,11223344566778899),…

然后通过另一种理解来检索,将每个元组的第一个元素作为名称,第二个元素作为ID

必须将ID转换为字符串,以便
.join()
工作,因此
str(i[1])


参考文献: