我正在用discord.py制作一个机器人,并使用AIOHTTP制作了一个meme命令。我希望嵌入的标题是到表情包的链接,页脚应该显示向上的投票和所有的东西,就像截图中一样。

以下是代码
@client.command(aliases=['memes'])
async def meme(ctx):
embed = discord.Embed(title='Meme', description=None)
async with aiohttp.ClientSession() as cs:
async with cs.get('https://www.reddit.com/r/wholesomememes/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, content=None)
```发布于 2021-05-18 19:52:21
用下面的代码替换它第一步:安装praw (pip install praw)第二步:转到https://www.reddit.com/prefs/apps创建应用程序第三步:复制client_id和client_secret第四步:运行机器人
@bot.command()
async def meme(ctx):
reddit = praw.Reddit(client_id='clientidhere',
client_secret='clientsecret',
user_agent='python')
memes = reddit.subreddit("memes").random()
await ctx.send(memes.url)https://stackoverflow.com/questions/67020724
复制相似问题