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

187
Views
Java S. No se puede leer la propiedad 'filtro' de undefined

Tengo esa pregunta porque ya no sé qué hacer. Tengo un BOT en Sugerencia para un determinado canal. Cuando ejecuto el bot a través de Visual Studio Code, el bot se ejecuta y todo funciona. Pero tan pronto como cargo un arranque en heroku.com, el programa de repente escribe un error:

archivos = archivos.filtro(f => f.terminaCon(".js"))

ingrese la descripción de la imagen aquí

Alguien podría ayudarme, sería muy feliz. Que tengas un lindo día

Index.js está aquí:

 client.once('ready', () => { console.log('Tutorial Bot is online!'); }); client.commands = new Discord.Collection() const fs = require("fs") fs.readdir("./commands/", (error, files) => { files = files.filter(f => f.endsWith(".js")) files.forEach(f => { const command = require(`./commands/${f}`) client.commands.set(command.name, command) console.log(`Command ${command.name} was loaded!`) }); }); client.on("message", message => { if (message.author.bot) return; if (message.channel.type === "dm") return; if (!message.content.startsWith(config.prefix)) return; const args = message.content.slice(config.prefix.length).split(" ") const command = args.shift() const cmd = client.commands.get(command) if (cmd) { cmd.run(client, message, args) } else return; }); bot.login(config.token);

Sugerir.js está aquí

 const { MessageEmbed } = require("discord.js"); module.exports = { name: "suggest", aliases: [], description: "Make a suggestion and have the community vote", category: "utility", usage: "suggest <suggestion>", run: async (client, message, args) => { let suggestion = args.slice(0).join(" "); let SuggestionChannel = message.guild.channels.cache.find(channel => channel.name === "suggestions"); if (!SuggestionChannel) return message.channel.send("Please create a channel named suggestions before using this command!"); const embed = new MessageEmbed() .setTitle("New Suggestion") .setDescription(suggestion) .setColor("RANDOM") .setFooter(`${message.author.tag} | ID: ${message.author.id}`) .setTimestamp() SuggestionChannel.send(embed).then(msg => { msg.react("👍🏼") msg.react("👎🏼") message.channel.send("Your suggestion has been sent!"); }); } }
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Olvidó verificar si hay errores en su devolución de llamada. En caso de error, los files no estarán undefined , lo que dará como resultado el error que ha observado. Así que deberías hacer algo como:

 fs.readdir("./commands/", (error, files) => { if(error) { // handle error } else { files = files.filter(f => f.endsWith(".js")) files.forEach(f => { const command = require(`./commands/${f}`) client.commands.set(command.name, command) console.log(`Command ${command.name} was loaded!`) }); } });
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!