如何更改嵌入中图像的位置

时间:2021-01-28 18:42:22

标签: python discord discord.py

我正在制作一个不和谐的机器人,它用用户的头像、成员 ID 和日期来回复命令,但问题是,它把图像放在嵌入的底部,我想把它放在嵌入之间标题和 ID/日期字段。我该怎么做?

我的代码:

import datetime

bot = discord.Client()
token = 'haha'

@bot.event
async def on_ready():
    print(f'{bot.user} has connected to Discord!')

@bot.event
async def on_message(message):
    if message.content.startswith('$test'):
        teste = message.author.mention
        authorId = message.author.id
        tempo = datetime.date.today().strftime("%d/%m/%Y")
        avatar = message.author.avatar_url_as(format='jpg', static_format='webp', size=2048)

        embed=discord.Embed(name="title", description=f"\U0001F5BC {teste} **alterou o avatar**", color=message.author.colour)
        embed.set_image(url=avatar)
        embed.add_field(name=f"ID do usuário: {authorId} • {tempo}", value="​")
        await message.channel.send(embed=embed)

bot.run(token)

enter image description here

1 个答案:

答案 0 :(得分:0)

这是 Discord 嵌入的一个更普遍的问题 - 布局有些固定。
您要么有字段,要么没有。

来自 discord.js guide 的这张插图做得很好:

enter image description here

所以你必须满足于其中之一:

  1. 使用 set_thumbnail 设置缩略图以使其显示在右侧。
    我认为这是一个可以接受的牺牲并节省一些空间。
  2. 使用 set_image 并使用 set_footer 将您的信息填入页脚。
    可以注意到,页脚以较小的字体显示,通常看起来不太好。
相关问题