【问题标题】:How do I have buttons in an embed like the picture below in discord.py? [closed]如何在 discord.py 中嵌入如下图所示的按钮? [关闭]
【发布时间】:2021-10-02 22:29:06
【问题描述】:

好的,我如何在嵌入中使用如上图所示的按钮。它在 discord.js 和 discord.py 中都可用吗?听说这是 Discord.py 的 alpha 版本,但是如何安装 alpha 版本呢?

【问题讨论】:

  • Soooo...你想只为 discord.py、只为 discord.js 还是两者都这样做?

标签: discord discord.py


【解决方案1】:

您需要使用以下命令从 master 分支安装 alpha 版本:

pip install -U git+https://github.com/Rapptz/discord.py

这是一个示例:请记住,这不是制作view 的最佳方法

@bot.command()
async def test_button(ctx)
    message = await ctx.send("Reference this message")

    # Establish an instance of the discord.ui.View class
    view = discord.ui.View()
    view.add_item(item=discord.ui.Button(style=discord.ButtonStyle.link,
                                         label="Go to message",
                                         url=message.jump_url
                                         )
                  )

    await ctx.send("Test of button", view=view)

来自大师的文档: discord.Button

【讨论】:

    猜你喜欢
    • 2021-11-29
    • 1970-01-01
    • 2021-08-16
    • 2021-12-27
    • 2017-08-07
    • 1970-01-01
    • 1970-01-01
    • 2021-03-21
    • 1970-01-01
    相关资源
    最近更新 更多