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

314
Views
¿Los módulos discord.js y node.js no se exportan correctamente? declaración devuelta no funciona

Así que estoy tratando de obtener un par de mensajes de un canal específico para obtener información sobre los 'clanes' que se registraron antes. Sin embargo, puedo buscar el canal y todo, y luego puedo filtrar y recorrer los mensajes devueltos, pero no puedo devolver los mensajes que obtuve, pase lo que pase. Sin error, sin nada, pero si llama a .getClans desde otro archivo, siempre devuelve indefinido.

 module.exports.getClans = (guild, channelid) => { var channel = guild.channels.cache.get(channelid); channel.messages.fetch({ limit: 10 }).then(messages => { messages = messages.filter(msg => msg.content && msg.content.startsWith("clan{") && msg.author.bot==true); return messages } ) }

Incluso he hecho cosas como

 module.exports.getClans = (guild, channelid) => { var channel = guild.channels.cache.get(channelid); channel.messages.fetch({ limit: 10 }).then(messages => { messages = messages.filter(msg => msg.content && msg.content.startsWith("clan{") && msg.author.bot==true); var returned = [] messages.forEach((el) =>{ returned.push(el) }) return returned; } ) }

que verifiqué en la función del módulo en sí devuelta se definió, pero llamar a la función nuevamente no devolvió nada más que indefinido. Por favor ayuda, no tengo ni idea de cómo solucionar esto.

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

0

En realidad, no está devolviendo nada de la función, solo está devolviendo .then(messages, ...) . Deberá recuperar lo que se está recuperando y luego regresar.

 module.exports.getClans = (guild, channelid) => { var channel = guild.channels.cache.get(channelid); //This return is returning from .getClans() return channel.messages.fetch({ limit: 10 }).then(messages => { messages = messages.filter(msg => msg.content && msg.content.startsWith("clan{") && msg.author.bot==true); //This return is returning from inside the .then() return messages } ) }
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!