discord.py - 我如何在嵌入 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 我需要帮助才能将标题和点赞数量放入嵌入中
解决方案
您可以通过设置这些属性
embed.title = "<your-title>"
embed.url = "https://<your-url>"
对于upvotes,您可以添加一个字段
embed.add_field(name = "Upvotes", value = "<your upvotes>")
推荐阅读
- mysql - 选择与同一表中的另一个字段相对应的每个不同字段
- python - 在 boto3 中创建/使用预签名 URL 时无法验证访问凭据
- cross-validation - 交叉验证 H2OStackedEnsembleEstimator?
- powershell - 按文件中的第一列排序
- postgresql - 查询速度太慢,只有 4 个表,每个表 50000 行
- django - 当表单上留空时,Django nullbooleanfield 默认为“False”,不应该为 Null 吗?
- python - 在许多 TIFF 文件中查找值的快速方法
- azure - Azure CosmosDB 以编程方式消耗吞吐量
- python - 如何在python中将完整的ascii字符串转换为十六进制?
- laravel - Laravel 上的多对多问题关系