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

201
Views
Discord.js V13 Set Button Cooldown

I have recently made my ticket bot, but I need to add a cooldown to the "close ticket" button to prevent someone from flooding the button and sending multiple messages, I haven't found any possible way to do that. How would I add a cooldown on a specific button?

My button code:

      const row = new client.discord.MessageActionRow()
        .addComponents(
          new client.discord.MessageButton()
          .setCustomId('confirm-close')
          .setLabel('Fechar o Ticket')
          .setStyle('DANGER'),
          new client.discord.MessageButton()
          .setCustomId('no')
          .setLabel('Cancelar Fechamento')
          .setStyle('SECONDARY'),
        );

        const verif = await interaction.reply({
          content: 'Tem certeza de que deseja fechar o ticket?',
          components: [row]
        });

For user identification, I'm using interaction.user.id

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

0

In general, you can do something like this for a cooldown:

let cooldownTime = 5000; //five seconds
let semaphore = true; //green

function doSomeStuff() {
    if (semaphore) {
        //your logic
        console.log("GREEN");
        semaphore = false; //red
        setTimeout(() => {semaphore = true;}, cooldownTime);
    } else {
        console.log("RED");
    }
}
<input type="button" value="CLICK ME!" onclick="doSomeStuff()">

This only affects the logic, but you can add button disabling/enabling to it as well.

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!