在Discord.py中的Embed中发送GIF

时间:2020-06-13 13:15:39

标签: python discord.py

@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,我很确定有办法。如果有,我不知道,很乐意向你们学习!

1 个答案:

答案 0 :(得分:1)

在嵌入中设置图片时,它必须是指向图片(https://example.com/path/to/image.png)的直接链接-如果您的网址以文件类型(.png,{{ 1}},.bmp.jpg等。

要获取此信息,您想右键单击您的图片/ gif,然后点击.gif

enter image description here

因此,您要:

Copy Image Location

参考: