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

363
Views
¿Por qué el controlador de comandos en discord.js no funciona?

Entonces, estaba desarrollando un Discord Bot y quería usar el controlador de comandos, pero hay algo mal con el ciclo for.

Código index.js:

 client.commands = new 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.data.name, command) }

Y este es el código de comando:

 module.export = { data: { name: "ban", description: "Ban an user" }, async execute(interaction){ //Code } }

El error me dice:

 client.commands.set(command.data.name, command) ^ TypeError: Cannot read properties of undefined (reading 'name') at Object.<anonymous> (/Users/yihanzhou/Desktop/LavaBot/index.js:13:38) at Module._compile (node:internal/modules/cjs/loader:1112:14) at Module._extensions..js (node:internal/modules/cjs/loader:1166:10) at Module.load (node:internal/modules/cjs/loader:988:32) at Module._load (node:internal/modules/cjs/loader:834:12) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12) at node:internal/main/run_main_module:17:47

¿Qué tiene de malo este código?

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

0

Es por un error:

module.export = {

en lugar de module.exports = {

aquí está !

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!