我对机器人进行编程的方式我不确定如何使消息通过来自不和谐的消息嵌入发送。我可以让它发送正常的消息,但嵌入不会工作,我知道我做错了什么。我有点新所以!
@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)
这是我的代码
答案 0 :(得分:0)
注意事项:
get_channel()
需要一个 ID 作为参数add_field()
需要名称和值set_footer()
至少需要文本修改后的代码:
# CHANNEL_ID is the id of the channel you want to send message to
@szn.event
async def on_message(message):
if message.content == 'info':
general_channel = szn.get_channel(CHANNEL_ID)
myEmbed = discord.Embed(title="test")
myEmbed.add_field(name="Field 1", value="Value 1")
myEmbed.set_footer(text="Footer")
await general_channel.send(embed=myEmbed)
答案 1 :(得分:0)
需要注意的是,如果您正在获取发送消息的频道,则可以执行 '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)
可能还有更多我不知道的嵌入内容,但这些应该很容易查找