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

75
Views
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 answers
Answer question

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 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!