Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

136
Vistas
TypeError: no se pueden leer las propiedades del controlador de comando no definido (leyendo 'ejecutar')
 const discord = require('discord.js') const client = new discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] }) const prefix = '&'; const fs = require('fs'); client.commands = 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, command); } client.on('ready', () => { console.log("================"); console.log("|Bot is ready|"); console.log("================"); }); client.on('message', message =>{ if(!message.content.startsWith(prefix) || message.author.bot) return; const args = message.content.slice(prefix.length).split(/ +/); const command = args.shift().toLowerCase(); if(command === 'ip'){ client.commands.get('ip').execute(message, args); } else if (command == 'creator'){ client.commands.get('creator').execute(message, args); } else if (command == 'rulespost'){ client.commands.get('rulespost').execute(message, args, discord); } else if(command == 'test'){ client.commands.get('test').execute(message, args); } })

Y con esto me sale un error con 'rulespost' diciendo TypeError: Cannot read properties of undefined (reading 'execute') y dentro de rulespost.js es

 module.exports = { name: 'RulesPost', description: "Posts the rules of the server", execute(message, args, discord) { const newEmbed = Discord.MessageEmbed() .setColor('#000000') .setTitle('Official Rules for ALL Platforms') .setDescription('...') .addFields( {value: 'TEXT'} ) message.channel.send(newEmbed) } }

Y al usar el comando &rulespost el bot muere y no pasa nada más. todos los demás comandos funcionan bien sin problemas, pero tratar de usar el comando incrustar mata al bot por completo.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Tenga en cuenta que esto es INCORRECTO, sin embargo, no se puede eliminar ya que está marcado por algún motivo.

la sintaxis de la función de ejecución es incorrecta. El intérprete piensa que está llamando a una función y luego pasando más elementos al objeto. esto se puede solucionar agregando la palabra clave de función o asignando ejecutar a una función anónima como esta:

 module.exports = { name: 'RulesPost', description: "Posts the rules of the server", // Execute is the key for the anon. function execute: function(message, args, discord) { const newEmbed = Discord.MessageEmbed() .setColor('#000000') .setTitle('Official Rules for ALL Platforms') .setDescription('...') .addFields( {value: 'TEXT'} ) message.channel.send(newEmbed) } }

Esto crea la función de ejecución que está exportando.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda