简体   繁体   English

如何发送嵌入 discord.py

[英]How to send embed with discord.py

I want to send embed message to a discord channel but in this way it doesn't work, did you have any idea?我想将嵌入消息发送到 discord 通道,但这样它不起作用,你知道吗?

@bot.command(
    name="my_first_command",
    description="This is the first command I made!",
    scope=[GUILD_ID],
)
async def my_first_command(ctx):
embed1 = discord.Embed(
        title=mob['name'],
        colour=0xE5E242,
        url=mob['url'],
        description="Famille: " + mob['type'],
    )
    embed1.set_image(url=mob['imgUrl'])
    embed1.add_field(name="Caractéristiques", value=stats, inline=False)

    await ctx.send(embed = embed1)

I got:我有:

Task exception was never retrieved
future: <Task finished name='Task-13' coro=<my_first_command() done, defined at bot.py:18> exception=TypeError("send() got an unexpected keyword argument 'embed'")>
Traceback (most recent call last):
  File "bot.py", line 40, in my_first_command
    await ctx.send(embed = embed1)
  File "/home/user/.local/lib/python3.8/site-packages/interactions/client/context.py", line 445, in send
    payload = await super().send(content, **kwargs)
TypeError: send() got an unexpected keyword argument 'embed'

Try to specify only the embed, then Python has to find out for itself which parameter it fits to.尝试仅指定嵌入,然后 Python 必须自己找出它适合哪个参数。 So try that:所以尝试一下:

@bot.command(
    name="my_first_command",
    description="This is the first command I made!",
    scope=[GUILD_ID],
)
async def my_first_command(ctx):
embed1 = discord.Embed(
        title=mob['name'],
        colour=0xE5E242,
        url=mob['url'],
        description="Famille: " + mob['type'],
    )
    embed1.set_image(url=mob['imgUrl'])
    embed1.add_field(name="Caractéristiques", value=stats, inline=False)

    await ctx.send(embed1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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