Discord按钮交互失败,但机器人反应正常,有办法删除按钮下的交互失败文本吗



所以我试图制作一个发送嵌入和按钮的discord机器人,当我使用按钮时,机器人会正常响应,但在按钮下,有一条文本说"交互失败";,这是代码

const akiLangEmbed = new MessageEmbed()
.setTitle(`${message.author.tag}`)
.setDescription(`Please Select Your Language`)
.setColor(client.config.embedcolor)
.setTimestamp()
const lang1 = new MessageActionRow().addComponents(
new MessageButton()
.setStyle("SUCCESS")
.setLabel("English")
.setCustomId("en"),
new MessageButton()
.setStyle("SUCCESS")
.setLabel("Indonesia")
.setCustomId("id"),
new MessageButton()
.setStyle("SUCCESS")
.setLabel("Japan")
.setCustomId("ja")
)
const lang2 = new MessageActionRow().addComponents(
new MessageButton()
.setStyle("SUCCESS")
.setLabel("Germany")
.setCustomId("gr"),
new MessageButton()
.setStyle("SUCCESS")
.setLabel("France")
.setCustomId("fr"),
new MessageButton()
.setStyle("SUCCESS")
.setLabel("Chinese")
.setCustomId("zh")
)
const langPick = await message.channel.send({ embeds: [akiLangEmbed], components: [lang1, lang2]})
const filter = (interaction) => {
if (interaction.user.id === message.author.id) return true;
return interaction.reply({
content: `Only ${message.author.tag} can use this interaction!`,
ephemeral: true,
});
};
const collector = langPick.createMessageComponentCollector({
filter,
componentType: "BUTTON",
time: 60000 * 5
})
collector.on("collect", async (interaction) => {
if(interaction.customId === "en") {
await akinator(message, {
language: "en",
useButtons: true,
embedColor: client.config.embedcolor
})
}
if(interaction.customId === "id") {
await akinator(message, {
language: "id",
useButtons: true,
embedColor: client.config.embedcolor
})
}
if(interaction.customId === "ja") {
await akinator(message, {
language: "ja",
useButtons: true,
embedColor: client.config.embedcolor
})
}
})

是的,我已经使用const导入了代码顶部所需的所有包,并且需要,有帮助吗

您需要推迟交互。将这一行粘贴到collector.on事件的第一行。

await interaction.deferUpdate();

相关内容

  • 没有找到相关文章