如何从机器人创建嵌入消息?

时间:2019-01-12 08:45:32

标签: python python-3.x discord.py

我对不和谐的机器人还很陌生,如果有人可以告诉我如何发出“嵌入”消息,我很想知道,例如:embedded image

这是我使用的代码:

@client.event async def on_message(message):
    if message.content == "=displayembed":
        embed = discord.Embed(
            title = "Title",
            description = "This is a description",
            colour = discord.Colour.blue()
        )

        embed.set_footer(text="This is a footer.")
        embed.set_image(url="https://cdn.discordapp.com/attachments/520265639680671747/533389224913797122/rtgang.jpeg")
        embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/520265639680671747/533389224913797122/rtgang.jpeg")
        embed.set_author(name="Author Name", icon_url="https://cdn.discordapp.com/attachments/520265639680671747/533389224913797122/rtgang.jpeg")
        embed.add_field(name="Field Name", value="Field Value", inline=False)
        embed.add_field(name="Field Name", value="Field Value", inline=True)
        embed.add_field(name="Field Name", value="Field Value", inline=True)

        await client.say(embed=embed)

1 个答案:

答案 0 :(得分:1)

@client.event
async def on_message(message):
    if message.content == "=displayembed":
        embed = discord.Embed(
            title = "Title",
            description = "This is a description",
            colour = discord.Colour.blue()
        )

        embed.set_footer(text="This is a footer.")
        embed.set_image(url="https://cdn.discordapp.com/attachments/520265639680671747/533389224913797122/rtgang.jpeg")
        embed.set_thumbnail(url="https://cdn.discordapp.com/attachments/520265639680671747/533389224913797122/rtgang.jpeg")
        embed.set_author(name="Author Name", icon_url="https://cdn.discordapp.com/attachments/520265639680671747/533389224913797122/rtgang.jpeg")
        embed.add_field(name="Field Name", value="Field Value", inline=False)
        embed.add_field(name="Field Name", value="Field Value", inline=True)
        embed.add_field(name="Field Name", value="Field Value", inline=True)

        await client.send_message(message.channel, embed=embed)`