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

76
Vistas
Discord.js timing out members

I'm using node.js to make a discord bot for my server, I am currently trying to timeout someone on command, e.g. 'Me-bot.timeout'... Response-'Bot-Who would you like to timeout?' then you type there username and it times them out. I thought this code would work but it doesn't, how do I fix it/what am I doing wrong?

message.guild.members.cache.get('username#1234').timeout(9000, 'Admin timed you out.')
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Firstly, as byxor mentioned, you should be using message.guild.members.fetch in Discord.js v12 and above.

That being said, fetch is going to return a Promise for a user, and not the user object itself. You need to handle this promise to get the resolved user before attempting to time them out.

This is all explained in the Discord.js documentation, but this is generally what you're looking for (with all possible errors caught if you need them):

message.guild.members.fetch('id')
  .then(user => {
    user.timeout(9000, 'Admin timed you out.')
    .then(() => {
      console.log('Timed user out for 9000 seconds.')
    })
    .catch(console.error)
  })
  .catch(console.error)

I would highly recommend you read up on Promises, as Discord.js is going to utilize them heavily.

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