@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)
This is my code. In if not ctx.channel.is_nsfw():
part i want to send a gif. I know that by default you can't send a gif I am pretty sure there is a way for it. If there is I don't know and would be happy to learn from you guys!
When setting an image in an embed, it needs to be the direct link to the image ( https://example.com/path/to/image.png ) - you'll know this if your url ends in a filetype ( .png
, .bmp
, .jpg
, .gif
etc.).
To get this, you want to right click your image/gif, and Copy Image Location
:
So in your case, you'd want:
embed.set_image(url="https://media0.giphy.com/media/W5C9c8nqoaDJWh34i6/giphy.gif")
Reference:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.