python - 我如何让我的机器人在响应来自不和谐的消息时发送嵌入
问题描述
我对机器人进行编程的方式我不确定如何通过来自不和谐的消息将消息作为嵌入发送。我可以让它发送正常的消息,但嵌入不会工作 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)
这是我的代码
解决方案
需要注意的是,如果您正在获取发送消息的频道,您可以执行“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)
嵌入可能还有更多我不知道的东西可以做,但这些应该很容易查找
推荐阅读
- angularjs - 在两个窗口之间共享变量。Angularjs
- excel - 如何使用 VBA Excel 合并两个以上的字符串而不会遇到运行时错误?
- c# - 我希望在加载大文件时避免表单冻结以显示
- select - 查询重复值并根据它们选择列值
- mysql - mysql 在 xampp 中停止工作,出现错误 InnoDB:文件(未知):“读取”返回操作系统错误 223
- ios - iOS 应用上的 BLE 热敏打印机字体配置
- javascript - 使用JSoup获取被onclick按钮javascript隐藏的表的内容
- ionic-framework - 如何使用 ionic 检查 NFC 是否适用于 iOS?
- javascript - 如何与 d3.js v5 中的元素以及缩放事件进行交互
- android - 将已发布的应用程序链接到 Firebase 控制台