【问题标题】:Rich Embed Buttons in Discord.pyDiscord.py 中的丰富嵌入按钮
【发布时间】:2021-08-16 10:17:12
【问题描述】:

我想知道如何在 Discord.py 中为我的 Discord 机器人添加丰富的嵌入消息按钮 像这样: Example

【问题讨论】:

标签: python discord.py


【解决方案1】:

您可以在文本中添加表情符号并向嵌入添加反应。

例如:

    if message.content.startswith(begin + "help"):
    embed = discord.Embed(title='{} Needs Help'.format(message.author),
                          description='Help for {}'.format(client.user.name),
                          color=message.author.color)
    embed.add_field(name="Title", value='description', inline=True)
    embed.set_footer(text="Bot by orty")
    embed.set_thumbnail(url=message.author.avatar_url)
    msg = await message.channel.send(embed=embed)
    await msg.add_reaction(client.get_emoji('Custom Emoji ID'))

【讨论】:

    【解决方案2】:

    此功能尚未在 Discord.py 中实现,它将用于 2.0(这是目前计划的),但已经很少有库可以实现它。 A good one is that of kiki700, Discord-Components

    【讨论】:

    • 你知道 Discord.py 2.0 什么时候发布
    • 您可以访问他们的服务器以获取更多信息,但要提前几个月。
    • 我建议使用 discord-interactions 因为 discord-components 不支持斜杠命令发送
    【解决方案3】:

    我也使用不和谐的按钮,因为它们很好。 我也遇到了这样的问题,我最终使用了这段代码:

    ticket = await channel.send(
        "_ _",
        components = [
            Button(label = "YOUR NAME", style=ButtonStyle.blue, emoji="?"),   
        ]
    )
    await client.wait_for("button_click", check = lambda i: i.component.label.startswith("YOUR NAME"))
    await test.respond(content="hello")
    

    所以这是我的代码。您不必在前面使用表情符号,但我认为它很好。

    【讨论】:

    • 我假设这是 discord-components 库?
    猜你喜欢
    • 2019-07-31
    • 2020-08-12
    • 2021-11-29
    • 2011-03-10
    • 2011-11-29
    • 2011-07-15
    • 2021-11-26
    • 2021-12-27
    • 2012-07-30
    相关资源
    最近更新 更多