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

147
Views
Problemas con el envío

Entonces, mi servidor tiene canales para cada usuario y el nombre del canal es su ID de usuario.

La forma en que quiero que funcione es;

Cuando un usuario envía un DM al bot con cualquier mensaje, el bot busca ese canal (el canal que se nombra como su ID de usuario) en el servidor y envía el contenido del mensaje que recibió en DM, pero sigo recibiendo un error:

 Cannot read property "send" of undefined

Aquí está mi código

 client.on("message", async (message) => { if (message.channel.type === "dm") { if (message.author.bot) return; var guild = client.guilds.cache.get("840120593311334410"); const cha = message.author.id; var hsa = await guild.channels.cache.find((ch) => ch.name === cha); hsa.send("test"); } });
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Hay 2 tipos de problemas que tengo para usted:

  1. El bot no tiene los permisos para ver el canal o el canal no existe. (Sin embargo, dijiste lo contrario en los comentarios)
  2. No tiene el canal en el caché: el código que usa se basa en el caché, lo que significa que debe asegurarse de tener los canales en caché. Use un GuildChannelManager.fetch() simple para almacenar en caché todos los canales.
 var guild = client.guilds.cache.get("840120593311334410"); const cha = message.author.id; await guild.channels.fetch(); //ONLY NEW LINE var hsa = await guild.channels.cache.find((ch) => ch.name === cha); hsa.send("test");
over 4 years ago · Santiago Trujillo 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!