首页 > 解决方案 > 我如何在嵌入 discord.py 中放置 meme 和 upvotes 的标题以及 meme 的链接

问题描述

@client.command(pass_context=True)
async def meme(ctx):
    embed = discord.Embed(title="", description="")

    async with aiohttp.ClientSession() as cs:
        async with cs.get('https://www.reddit.com/r/dankmemes/new.json?sort=hot') as r:
            res = await r.json()
            embed.set_image(url=res['data']['children'] [random.randint(0, 25)]['data']['url'])
            await ctx.send(embed=embed)

所以这是我的模因命令 rn 我需要帮助才能将标题和点赞数量放入嵌入中

标签: discord.py

解决方案


您可以通过设置这些属性

embed.title = "<your-title>"
embed.url = "https://<your-url>"

对于upvotes,您可以添加一个字段

embed.add_field(name = "Upvotes", value = "<your upvotes>")

推荐阅读