Estoy trabajando en discord.js bot V13 y encontré este error
Código:
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() }Ayuda con: solo quiero convertir la cadena (command.name.toLowerCase()) pero envía un error que también probé en VScode pero envía un error, también el error es el mismo Error:
TypeError: no se puede leer la propiedad 'toLowerCase' de undefined
Cualquier información por favor no dude en preguntar.
Usa .toLowerCase() en tu evento
P.ej:
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) } })