Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

84
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda