python - Embedding Gifs in Discord Bot
问题描述
So I am making a discord Bot which has a command to send random reddit submissions.
If the bot hit's an image everything is fine, but if it's a gif it is only displayed in the Pycharm console, not sent do discord (the poop emoji appears)
I am using praw to fetch the reddit content.
In the attached images is the command itself as well as my embed function and the output in Pycharm/Discord.
In my screenshot the image is a png and works. When it's a gif it's loading for a few seconds and shows the poop emoji, like nothing found. In Pycharm it's printing the image path.
As I've seen Bots posting them as embeds they get sent, so it seems to work..
解决方案
你好。Discord 将所有图像添加为附件。
这是您可以执行的操作:
#PS 我假设您是在命令中编写它并进行了嵌入设置。
img=<path of image>
file = discord.File(img)
embed.set_image(url="attachment://image.gif")
await ctx.send(file=file, embed=embed)
推荐阅读
- xml - 无法找到包含回车的 xpath 元素文本
- python - 如何在python中的对象列表中求和元素
- python - Plotly Express scatter_mapbox 不在 Dash 中呈现
- mongodb - 连接到主机时出错:无法连接到服务器:服务器选择错误:服务器选择超时当前拓扑:类型:单服务器
- c++ - 如何将数据包缓冲区解析为结构
- git - Git 使用树形哈希将先前的提交恢复为新的提交
- java - 在 Java 中,为什么我可以将 double 添加到 int 但不能将 double 分配给 int?
- hyperledger-fabric - Hyperledger Fabric 资产/数据可以是十进制值还是只有整数?
- c# - 将英国格式的字符串 DateTime ("dd/MM/yyyy") 转换为文化可能发生变化的有效 DateTime
- amazon-web-services - Fn::GetOptionSetting 在 AWS ElasticBeanstalk 中不起作用