【发布时间】:2020-08-12 11:20:01
【问题描述】:
@commands.command(aliases=['gt'])
async def cat(self, ctx):
"""Outputs image from r/greentext"""
async with ctx.typing():
async with aiohttp.ClientSession() as cs:
async with cs.get("https://www.reddit.com/r/greentext/hot/.json") as r:
data = await r.json()
embed = discord.Embed(title = "r/greentext", color = 0xFF0000)
embed.set_image(url = data["url"])
embed.set_footer(text = "r/greentext")
await ctx.send(embed = embed)
我知道 data["url"] 应该是正确的,因为这就是图像文件在网站上保存的内容 如此屏幕截图所示:https://imgur.com/a/kTl0BOW 整个网站的json在这里:https://www.reddit.com/r/greentext/hot/.json 如果有人可以帮助我,我找不到 aiohttp 帮助服务器,而 discord.py 服务器根本没有帮助我,因为它们都让你觉得需要帮助很愚蠢
【问题讨论】:
-
如果您的问题得到解答,请将其标记为solved
标签: python reddit aiohttp discord.py-rewrite