【问题标题】:Getting the url of a video of a new post using PRAW and send it to a discord server (praw, discord.py)使用 PRAW 获取新帖子视频的 url 并将其发送到不和谐服务器 (praw, discord.py)
【发布时间】:2021-07-04 18:48:52
【问题描述】:

我正在尝试在我的 discord.py 机器人中发出一个命令,以发送附加到 reddit 帖子的图像或视频。 但是,当帖子带有图片时,一切正常……当帖子包含视频时,结果如下:

现在我有这个:

@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

没有回溯,因为我没有收到任何错误...

【问题讨论】:

    标签: python discord.py bots reddit praw


    【解决方案1】:

    Discord 的 API 不允许您在嵌入中使用自定义视频,如 this other question 所示。看看函数的名字,它是set_image。如果您想在其中放置视频,也许将其转换为 gif 即可。

    【讨论】:

    猜你喜欢
    • 2020-12-24
    • 2013-03-04
    • 1970-01-01
    • 2023-04-03
    • 2014-09-25
    • 2020-12-09
    • 2018-09-19
    • 2020-09-20
    • 2021-11-05
    相关资源
    最近更新 更多