按钮"/>
使用后禁用按钮
我在我的
index.js
中写了这个,以便在按下按钮然后禁用它时回复。
client.on("interactionCreate", async (interaction) => {
if (interaction.isButton()) {
if (interaction.customId === "yes") {
const owner_role = await db.get(`Owner-${interaction.guild.id}`);
if (!owner_role) {
return interaction.reply({ content: `:no: The server's owner haven't set up the bot yet. Please contact them.`, ephemeral: true })
};
if (!interaction.member.roles.cache.has(owner_role)) {
return interaction.reply({ content: ":no: You don't have permission to use this command.", ephemeral: true })
};
interaction.reply(`This suggestion has been approved by ${interaction.user}.`)
// Disable the button
}
我唯一不知道的是我如何禁用按钮。
有人可以帮忙吗?
回答如下:您可以使用新的
MessageActionRow
创建一个新的MessageButton
并使用setDisabled(true)
禁用它
await interaction.reply(`This suggestion has been approved by ${interaction.user}.`);
const row = new MessageActionRow()
.addComponents(
new MessageButton()
.setCustomId('customId')
.setLabel('some label')
.setDisabled(true)
);
await interaction.editReply({ components: [row] });
更多推荐
使用后禁用按钮
发布评论