简体   繁体   中英

How do I add a url in embed.add_field discord.py?

I am trying to make it so I can have different URLs on different areas of an embed, is there a way to do this in embed.add_field ?

My code:

@bot.command()
async def status(ctx):
    embed=discord.Embed(title="Bot Status", color=ctx.author.color, timestamp=ctx.message.created_at)
    embed.set_author(name=ctx.author.name, icon_url=ctx.author.avatar_url)
    embed.add_field(name="replit.com", url="https://Eternalia-Development.malakaishryock.repl.co")
    embed.add_field(name="betteruptime.com", url="https://eternalia-na.betteruptime.com/")
    await ctx.send(embed=embed)

Whenever I run the command !status , I get the error: discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: add_field() got an unexpected keyword argument 'url'

There is no url value for an embed field. Instead of using url, use value.

Like this:

embed.add_field(name="replit.com",value = "https://Eternalia-Development.malakaishryock.repl.com")

Mika Tan's answer should work fine, however if you want your link to be a hyperlink like ' this '. Use

embed.add_field(name="replit.com", value="[Here is the link](url)")

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