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

135
Views
Update discord-buttons on InteractionCreate

In Discord MessageButtons, MessageActionRow

I'm having a MessageActionRow() running into a message embed, added buttons addComponents to that message, on createInteraction when a "PauseButton" is clicked, the button replaces with another button called "ResumeButton", same same.

const PauseButton = new MessageButton()
.setCustomId('PauseButton')
.setLabel('Pause')
.setStyle('SUCCESS')
.setEmoji('⏸️');

const ResumeButton = new MessageButton()
.setCustomId('ResumeButton')
.setLabel('Resume')
.setStyle('SUCCESS')
.setEmoji('▶️');

//SkipButton, StopButton

const Buttons = new MessageActionRow().addComponents(PauseButton, SkipButton, StopButton);
const ResumeButtons = new MessageActionRow().addComponents(ResumeButton, SkipButton, StopButton);

const sendMessage = await QueueChannel.send({ embeds: [sendMessageEmbed], components: [Buttons] });

this.client.on('interactionCreate', async interaction => {
if (!interaction.isButton()) return;
// Pause
if (interaction.customId === "PauseButton") {
    player.pause(true);
    const int = await interaction.deferUpdate({
      fetchReply: true,
    });
    if (!int) return smt
    await int.edit({
      components: [ResumeButtons],
    });
    if(int.deleted) {
      interaction.channel.send()
    }
    }
// Resume
if (interaction.customId === "ResumeButton") {
    player.pause(false);
    const int = await interaction.deferUpdate({
      fetchReply: true,
    });
    if (!int) return smt
    await int.edit({
      components: [Buttons],
    });
    if(int.deleted) {
      interaction.channel.send()
    }
}

This returns the error DiscordAPIError: Unknown interaction ln line 23:13 await interaction.deferUpdate on await.

Basically, the code does the job (it works fully functional) except: On the First run, everything works fine, On the Second run, when I click any button, an error returns "Unknown interaction" and the reason is that the the code is running twice, I knew when I added console.log("PauseButton") on the interact, the log returned twice to console PauseButton PauseButton instead of once.

Meaning there are 2 listeners for the ineractionCreate or something? Do I need to remove any interaction when the message is removed?

I need help please, anything is appreciated!

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The process was duplicating because I had an interactionCreate.js in that project. I felt so confused because there was so many files, code has no issues, my apologize.

about 4 years ago · Juan Pablo Isaza 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!