简体   繁体   中英

discord.py how to add an image to embed.add_field

How can I add a local image in the value of embed.add_field(name=f'Last Match ({status})', value=

    file = discord.File(f"{icon_full_path}", filename=f"{icon_png}")
    embed = discord.Embed(title=f'**{name}**', description=f'Summoner Level: {level}')
    embed.set_thumbnail(url=f'attachment://{icon_png}')
    embed.add_field(name='Ranked (Solo/Duo)', value=f'{full_rank}')
    embed.add_field(name=f'Last Match ({status})', value=f'{kills} / {deaths} / {assists} \n {minions}<:minion:823209384908816404> \t {gold}<:gold:823209384942370836>')
    await ctx.send(file=file, embed=embed)

We cannot add image in the value field of add_field . Please refer to discord.Embed for all the functions of discord.Embed class.

We use set_image to set image ( big in size ) and set_thumbnail to set an image to the top right of the embed ( like a logo ).

Depending on your usage you can use anyone of them.

If you want to embed local images you can refer to this page on discord py api.

Use add_image add images

embed = discord.Embed(title = 'hi', description = 'cheese',color = discord.Colour.blue())
embed.add_image(url = 'insert random url here')
await message.channel.send(embed=embed)

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