Search code examples
pythondiscord.pybotsredditpraw

Getting the url of a video of a new post using PRAW and send it to a discord server (praw, discord.py)


I'm trying to make a command in my discord.py bot that send the image or the video attacched to a post in reddit. But, when a post is with an Image, all works fine... when the post contains a video, that's the results:

enter image description here

for now I have this:

@client.command()
async def meme(ctx):
    subreddits = ['memesITA','yesyesyesyesno','nonononoyes','technicallythetruth','WatchPeopleDieInside','Wellthatsucks','hmmm']
    probs = [1,2,3,4,5,6,7,8,9,10]
    choice = random.choice(subreddits)
    choice_num = random.choice(probs)
    count = 0
    new_messages = choice.new(limit=10)

    for post in new_messages:
        if count == choice_num:
            img_url = post.url
            title = post.title

            em = discord.Embed(title=title)
            em.set_image(url=img_url)

            await ctx.send(embed=em)

            break

        count = count + 1

There is no traceback because I don't receive any error...


Solution

  • Discord's API doesn't let you use custom videos in embeds, as seen in this other question. Just look at the function's name, it's set_image. If you want to place a video there, maybe converting it to gif will work.