首页 > 解决方案 > 我如何让我的机器人在响应来自不和谐的消息时发送嵌入

问题描述

我对机器人进行编程的方式我不确定如何通过来自不和谐的消息将消息作为嵌入发送。我可以让它发送正常的消息,但嵌入不会工作 idk 我做错了什么。我有点新!

@szn.event
async def on_message(message):

    if message.content == 'info':
        general_channel = szn.get_channel()

        myEmbed = discord.Embed(tiitle="test", description="", color="")
        myEmbed.add_field()
        myEmbed.set_footer()

        await general_channel.send(embed=myEmbed)

这是我的代码

标签: pythonpython-3.xdiscorddiscord.pyembed

解决方案


需要注意的是,如果您正在获取发送消息的频道,您可以执行“message.channel”

async def on_message(message):
    if message.content == 'info':
        myEmbed.title = "[insert the title of the embed]"
        myEmbed.description = '[insert the description of the embed]'
        myEmbed.color = 0xfc0303 [hex color, you can search up hex colors and then put '0x' in front of it] #this is optional
        myEmbed.set_footer(text = "[text]") #also optional
        myEmbed.set_image(url = "[image URL]") #again, optional
        await message.channel.send(embed=myEmbed)

嵌入可能还有更多我不知道的东西可以做,但这些应该很容易查找


推荐阅读