【发布时间】: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