discord - discord.py 无法从本地文件嵌入图像
问题描述
我使用此代码嵌入图像,它不会引发任何错误并且它发送嵌入但嵌入中没有任何内容。
e=discord.Embed()
file = discord.File("OWO.jpg", filename="OWO.jpg")
e.set_thumbnail(url="attachment://OWO.jpg")
msg = ctx.send(embed=e)
这是我嵌入图像的样子,里面什么都没有。
解决方案
如何将本地图像文件用于嵌入图像?
Discord 特殊情况上传图像附件并在嵌入中使用它,这样它就不会单独显示,而是在嵌入的缩略图、图像、页脚或作者图标中显示。
为此,请使用 abc.Messageable.send() 正常上传图像,并将嵌入的图像 URL 设置为 attachment://image.png,其中 image.png 是您将发送的图像的文件名。
快速示例:
file = discord.File("path/to/my/image.png", filename="image.png")
embed = discord.Embed()
embed.set_image(url="attachment://image.png")
await channel.send(file=file, embed=embed)
注意:由于 Discord 的限制,文件名可能不包含下划线。
是否存在创建审核日志条目的事件?
推荐阅读
- mongodb - 邮递员应用程序显示无法连接到服务器的错误
- lua - Lua 错误:Main.lua:131:尝试索引本地“向上”(一个 nil 值)堆栈回溯:
- javascript - 与 Safari 和 Apple Pay 模式交互
- apache-kafka - KSQL Join 流与结构字段上的条件
- android - 安全购买溢价 IAP
- python - ResourceWarning:运行python selenium unittest时出现未关闭的文件错误
- azure - Azure 资源管理器模板:条件部署
- c# - 附加到较新版本的 LocalDb 时防止更新 MDF 文件
- ios - SwiftUI:获取动态背景颜色(深色模式或浅色模式)
- laravel - 如何在 laravel 分页中获得总结果?