【发布时间】:2021-10-02 22:29:06
【问题描述】:
好的,我如何在嵌入中使用如上图所示的按钮。它在 discord.js 和 discord.py 中都可用吗?听说这是 Discord.py 的 alpha 版本,但是如何安装 alpha 版本呢?
【问题讨论】:
-
Soooo...你想只为 discord.py、只为 discord.js 还是两者都这样做?
标签: discord discord.py
好的,我如何在嵌入中使用如上图所示的按钮。它在 discord.js 和 discord.py 中都可用吗?听说这是 Discord.py 的 alpha 版本,但是如何安装 alpha 版本呢?
【问题讨论】:
标签: discord discord.py
您需要使用以下命令从 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
【讨论】: