Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

293
Vistas
How do I make a discord-bot stop replying after I write "shut up"?

I started on this small project just for fun for my friend's server. She wanted to have the bot reply to her any time she said anything in her server and she wanted the bot to stop replying after an hour after saying "shut up" (no prefixes). I currently have this

client.on("message", function (message) {
const amyID = "blahblah";
const jayID = "blahblah";
if (message.author.id == (jayID)) {
    if (message.content.includes("shut up")) {
        message.reply("sorry...")
        setTimeout(function () {

        }, 60000)
    } else {
        client.commands.get('replyToAmy').execute(message);
    }
  }
})

setTimeout seems to only work with functions which I am confused on how I can apply it to the client.on bit. If I remove setTimeout the bot will start responding again. How can I make the bot stop responding for a set amount of time after "shut up" is said by the user?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

One way to do that would be create a boolean variable outside the client.on('message') function. Then the bot will keep sending a message as long as the boolean variable is set to true. Once the user tells the bot to stop, the boolean variable is set to false and you can create a .setTimeout() for the specified time after which the boolean variable will turn back to true. And then all we have to do is check if the boolean variable is true or not every time we send the message. The code might look something like this:

let keepReplying = true
const userId = 'the users id'
client.on('message', message => {
    if (message.author.id === userId) {
        if (message.content === 'stop') {
            keepReplying = false
            setTimeout(() => { keepReplying = true }, 60000)
        }
    }
    if (keepReplying) client.commands.get('replyToAmy').execute(message);
})
about 4 years ago · Juan Pablo Isaza Denunciar

0

Maybe Create a list to contain the user who said shut up & timestamp then function to check user from that list and compare time with timestamp?

well if user timestamp > 1 hr then delete that from the list

there's a better way tho but this is the easy route. and not the most effective way as it would be too much waste with many users

but from your code seem like you just made small project for small group of users so there's no problem

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda