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

298
Views
TypeError: Cannot read properties of undefined (reading 'has')

I am currently trying to do a cooldown, the code is not mine, but would like to understand why I am getting this error and wonder how to fix it

const cooldowns = new Map();

if(cooldowns.has(command.name)) {
    cooldowns.set(command.name, new Discord.Collection())
}

const current = Date.now()
const time_stamps = cooldowns.get(command.name)
const cooldown = (command.cooldown) * 1000;

if(time_stamps.has(message.author.id)) {
    const expiration = time_stamps.get(message.author.id) + cooldown

    if(current < expiration) {
        const time = (expiration - current) / 1000;
        return message.reply("message")
    }
}
time_stamps.set(message.author.id, current);
setTimeout(() => time_stamps.delete(message.author.id), cooldown);

Error:

if(time_stamps.has(message.author.id)) {
               ^
TypeError: Cannot read properties of undefined (reading 'has')
about 4 years ago · Juan Pablo Isaza
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!