简体   繁体   中英

How do I change the position of an image on an embed

I'm making a discord bot that replies commands with the user's avatar, member id, and date, but the problem is, it's putting the image at the bottom of the embed, and I would like to have it between the embed title and the id/date field. How do I do that?

My code:

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)

在此处输入图像描述

This is a more general issue with Discord embeds - the layout is somewhat fixed.
You either have fields or you don't.

This illustration from discord.js guide does a good job:

在此处输入图像描述

So you would have to settle for either:

  1. Set the thumbnail using set_thumbnail to have it shown on the right.
    I think it's an acceptable sacrifice and saves some space.
  2. Use set_image and cram your information into the footer using set_footer .
    As can be noted, the footer ris shown in a smaller font and generally looks less good.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM