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

137
Views
indefinido (leyendo 'videos')

Intento que un bot de Discord se una a un canal y reproduzca un enlace, pero aparece este error

 TypeError: Cannot read properties of undefined (reading 'videos')

mi controlador de comandos está bien con otros comandos más simples

 const videoFinder = async (query) => { const videoResult = await ytSearch(query); return (videoResult.videos.length > 1) ? videoResult.videos[0] : null; }

Esta es la línea que me da el error.

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

0

Puedes intentar algo como esto:

 const videoFinder = async (query) => { const videoResult = await ytSearch(query); return (videoResult?.videos?.length > 1) ? videoResult?.videos[0] : null; }

el ? comprobará el objeto antes de que exista. Si no, devuelve undefined y, en su caso, nulo, porque undefined.videos no existe.

Alternativamente:

 const videoFinder = async (query) => { const videoResult = await ytSearch(query); if (!videoResult || !videoResult.videos) return null return videoResult.videos[0] }
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!