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

328
Views
Discord.js command.name.toLowerCase() is not working

I'm working on discord.js bot V13 and I came across this error

Code:

client.commands = new Discord.Collection();
const cooldowns = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
    const command = require(`./commands/${file}`);
    client.commands.set(command.name.toLowerCase(), command);//Errors at command.name.toLowerCase()
}

Help With: I just want to convert The string (command.name.toLowerCase()) but it sends an error i have also tried in VScode but it sends error there also error is same Error:

TypeError: Cannot read property ‘toLowerCase’ of undefined

Any information please do not hesitate to ask.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Use .toLowerCase() in your event

Eg:

client.on("messageCreate", async message =>{
    if(!message.content.startsWith(prefix)) return;
    const args = message.content.slice(prefix.length).trim().split(' ')
    const cmd = args[0].toLowerCase()
    const command = client.commands.get(cmd)
    if(!command) return;
    try{
       await command.execute(message, args)
    } catch(e){
        console.log(e)
    }

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