【问题标题】:discord.py having problems with praw embedingdiscord.py 对虾嵌入有问题
【发布时间】:2020-11-20 23:27:47
【问题描述】:

这是我的代码,嵌入部分不起作用

@Bot.command()
async def meme(ctx):
    embed=discord.Embed(title="MEME TIME", color=0x57d8e9)
    memes_submissions = reddit.subreddit('memes').top()
    post_to_pick = random.randint(1, 100)
    for i in range(0, post_to_pick):
        submission = next(x for x in memes_submissions if not x.stickied)
    embed.add_field(submission=submission)
    await ctx.send(Embed=embed)

【问题讨论】:

  • 如果您遇到错误,您可以将其与您的问题一起发布在这里

标签: python-3.x discord.py-rewrite praw


【解决方案1】:

您的代码有多个问题。

  • 嵌入需要描述。您可以通过提供粗体空格来创建空描述:** **

  • 您的添加字段代码也错误。它没有submission 字段。它有一个name、一个value 字段和一个inline 布尔值。

  • 您的随机命令将始终获得最高职位。设计不当。

这是一个从您的代码修改的示例,应该可以完成工作:

@Bot.command()
async def meme(ctx):
    embed=discord.Embed(title="MEME TIME", description="** **", color=0x57d8e9)
    randomPost = random.randint(1, 100)
    Listposts = [post for post in reddit.subreddit('memes').top(limit=100)]
    post = Listposts[randomPost]
    embed.add_field(name=post.title, value=post.author)
    embed.set_image(url=post.url)
    await ctx.send(Embed=embed)

可以在here找到一个帮助您进行嵌入结构和设计的小工具。

【讨论】:

    猜你喜欢
    • 2012-07-09
    • 2021-07-25
    • 2020-12-31
    • 1970-01-01
    • 1970-01-01
    • 2022-01-01
    • 2020-12-09
    • 2022-01-19
    • 1970-01-01
    相关资源
    最近更新 更多