Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

450
Views
interaction failed without any reason discord.js v13

I was making a simple coinflip command in my discord bot. It is working but makes an "Interaction Failed" event without reason. It edits the embed and changes things it should change. and it deletes the message without any problem.

My Code:

const randomResult = Math.floor(Math.random() * 2) == 0 ? "Heads" : "Tails";

const embed = new MessageEmbed()
.setTitle("Coin Flip")
.setColor("YELLOW")
.setDescription(` > ${randomResult}`)
.setFooter({
text: `Requested by ${message.author.username}`,
iconURL: message.author.displayAvatarURL(),
});

const row = new MessageActionRow().addComponents(
new MessageButton()
.setCustomId("again")
.setLabel("Throw Again")
.setEmoji("๐Ÿ”")
.setStyle("PRIMARY"),

new MessageButton()
.setCustomId("delete")
.setLabel("Delete")
.setEmoji("โ™ป")
.setStyle("DANGER")
);
message.channel.send({ embeds: [embed], components: [row] }).then(msg => {
global.msg = msg;
})
const iFilter = (i) => i.user.id === message.author.id;
const collector = message.channel.createMessageComponentCollector({
filter: iFilter,
time: 30000,
});
collector.on("collect", async (i) => {
if (i.customId === "again") {
const randomResult =
Math.floor(Math.random() * 2) == 0 ? "Heads" : "Tails";
const newEmbed = new MessageEmbed()
.setTitle("Coin Flip")
.setColor("YELLOW")
.setDescription(` > ${randomResult}`)
.setFooter({
text: `Requested by ${message.author.username}`,
iconURL: message.author.displayAvatarURL(),
});
const row = new MessageActionRow().addComponents(
new MessageButton()
.setCustomId("again")
.setLabel("Throw Again")
.setEmoji("๐Ÿ”")
.setStyle("PRIMARY"),
new MessageButton()
.setCustomId("delete")
.setLabel("Delete")
.setEmoji("โ™ป")
.setStyle("DANGER")
);
msg.edit({ embeds: [newEmbed], components: [row] });
}
if (i.customId === "delete") {
msg.delete();
}
})
collector.on("end", async (i) => {
const newEmbed2 = new MessageEmbed()
.setTitle("Coin Flip")
.setColor("YELLOW")
.setDescription(` > ${randomResult}`)
.setFooter({
text: `Requested by ${message.author.username}`,
iconURL: message.author.displayAvatarURL(),
});
const row = new MessageActionRow().addComponents(
new MessageButton()
.setCustomId("ended")
.setLabel("Coin Flip Ended")
.setEmoji("โŽ")
.setStyle("DANGER")
.setDisabled(true),
);
msg.edit({embed: [newEmbed2], components: [row]})
})

Note: I am not getting any errors. I am using discord.js v13 and node.js v16

about 4 years ago ยท Santiago Gelvez
1 answers
Answer question

0

You still have to reply to the interaction using Interaction#reply() method. This is to acknowledge to discord that you handled the interaction. Something like interaction.reply("success") will probably do the job

about 4 years ago ยท Santiago Gelvez Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
ยฉ 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!