可以在 Discord.js 中嵌入按钮吗?

Ank*_*omm 3 javascript discord discord.js

不久前我创建了一个 Discord 机器人,它使用 BetaSeries API 打印给定节目的下一集的日期,但是当机器人遇到一个节目的多个结果时,它会显示 API 返回的节目列表。在这一点上,我的机器人要求再次使用节目的 ID(显示在列表中)编写命令,但我正在寻找一种方法来创建带有按钮的列表,当单击按钮时,按钮会自动显示显示信息而无需编写带有 ID 的命令。

小智 6

是的,这是可能的,许多机器人使用不和谐的反应来模拟按钮,让机器人对要求选择具有不同表情符号(通常是 1、2、3 等表情符号)的选项的消息做出反应,并获取是否某个用户对消息做出了反应。

有关如何获取反应事件的更多信息,请参阅收集使用 discord.js消息作出反应的用户


Dan*_*der 6

As of May 2021, Buttons are officially implemented in the discord API. At this point of time, there are unofficial wrappers that support adding buttons

自定义按钮

Update ( July 2021 ):

Buttons will be a part of discord.js v13 and higher. Refer to this PR to stay updated