Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何从机器人程序创建嵌入消息?_Python_Python 3.x_Discord.py - Fatal编程技术网

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

Python 如何从机器人程序创建嵌入消息?,python,python-3.x,discord.py,Python,Python 3.x,Discord.py,我对discord机器人相当陌生,如果有人能告诉我如何制作“嵌入”消息,我会很高兴,下面是一个例子: 以下是我使用的代码: @client.event async def on_message(message): if message.content == "=displayembed": embed = discord.Embed( title = "Title", description = "This is a des

我对discord机器人相当陌生,如果有人能告诉我如何制作“嵌入”消息,我会很高兴,下面是一个例子:

以下是我使用的代码:

@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)

我很困惑。您显示代码(看起来很好)-您显示嵌入消息的图片。。。但是两者都有什么问题?您应该将client.say替换为bot.send_message(message.channel,embed=embed),因为client.say只能在命令decorcorclient.send_message中使用*
@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)`