python - 在 Discord.py 中的嵌入中发送 gif
问题描述
@client.command(aliases=["rule34"])
async def nsfw(ctx):
if not ctx.channel.is_nsfw():
embed = discord.Embed(
title=":x: Channel Is Not NSFW",
color=discord.Colour.purple()
)
embed.set_image(url="https://giphy.com/gifs/W5C9c8nqoaDJWh34i6")
else:
async with ctx.channel.typing():
memes_submissions = reddit.subreddit("rule34").hot()
post_to_pick = random.randint(1, 10)
for i in range(0, post_to_pick):
submission = memes_submissions.__next__()
embed = discord.Embed(
title=submission.title,
color=discord.Colour.purple()
)
embed.set_image(url=submission.url)
embed.add_field(name="Author", value="u/" + submission.author.name, )
embed.add_field(name="View Online", value=f"[Link]({submission.url})", )
embed.add_field(name="Subreddit", value="r/rule34", )
await ctx.send(embed=embed)
这是我的代码。在if not ctx.channel.is_nsfw():
某种程度上,我想发送一个 gif。我知道默认情况下你不能发送 gif 我很确定有办法。如果有我不知道,很乐意向你们学习!
解决方案
在嵌入中设置图像时,它必须是图像的直接链接 ( https://example.com/path/to/image.png ) - 如果您的 url 以文件类型 ( .png
, .bmp
,.jpg
等.gif
)。
为此,您需要右键单击您的图像/gif,然后Copy Image Location
:
所以在你的情况下,你会想要:
embed.set_image(url="https://media0.giphy.com/media/W5C9c8nqoaDJWh34i6/giphy.gif")
参考:
推荐阅读
- c - 如何访问指针数组中的指针所指向的值?
- javascript - 资源加载后启动three.js
- javascript - 如何使用 GET 请求重新加载页面并保持滚动位置?
- android - 向用户显示消费者密钥 [PARSE SERVER]
- node.js - 为什么 process.nextTick() 被调用了 3 次?
- sql - sql - 计算平均值时的结果小数精度和比例
- docker - 待处理的詹金斯没有标签 docker-slave
- android - Android - 如何通过 GSON 表示来自 URL 的 JSON 信息
- php - symfony2.8 @ORM\HasLifecycleCallbacks() 不工作
- ios - 将 Apple ID 链接到我的服务器上的多个帐户/用户