首页 > 解决方案 > 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..

Python code

标签: pythonpycharmdiscorddiscord.pyreddit

解决方案


你好。Discord 将所有图像添加为附件。

这是您可以执行的操作:

#PS 我假设您是在命令中编写它并进行了嵌入设置。

img=<path of image>
file = discord.File(img)
embed.set_image(url="attachment://image.gif")
await ctx.send(file=file, embed=embed)

推荐阅读