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

242
Views
Discord.js V13 Player no está definido

Estoy construyendo un bot de música discord.js v13.6.0 y todo funciona excepto este código

 const { QueryType } = require('discord-player'); module.exports = { name: 'play', aliases: ['p'], utilisation: '{prefix}play [song name/URL]', voiceChannel: true, async execute(client, message, args) { if (!args[0]) return message.channel.send(`${message.author}, Write the name of the music you want to search. ❌`); const res = await client.player.search(args.join(' '), { requestedBy: message.member, searchEngine: QueryType.AUTO }); if (!res || !res.tracks.length) return message.channel.send(`${message.author}, No results found! ❌`); const queue = await client.player.createQueue(message.guild, { metadata: message.channel }); try { if (!queue.connection) await queue.connect(message.member.voice.channel); } catch { await client.player.deleteQueue(message.guild.id); return message.channel.send(`${message.author}, I can't join audio channel. ❌`); } await message.channel.send(`Your ${res.playlist ? 'Your Playlist' : 'Your Track'} Loading... 🎧`); res.playlist ? queue.addTracks(res.tracks) : queue.addTrack(res.tracks[0]); if (!queue.playing) await queue.play(); }, };

Cuando uso este comando, ocurre el siguiente error:

 Unhandled promise rejection: ReferenceError: player is not defined

Soy nuevo en la programación, lo siento por los errores tontos, si necesita información no dude en preguntar

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

0

La posibilidad de tales errores aparece al lanzar dentro de una función asíncrona sin un bloque catch o al rechazar una promesa que no tenía un .catch()

Podrías estar haciendo:

  1. coloca su código dentro de una función asíncrona para usar llamadas en espera .
  2. La función esperada falla.

Las soluciones son:

  1. O usa .catch()
 await returnsPromise().catch(e => { console.log(e) })

o

2.Utilice el bloque de prueba/captura

 try { await returnsPromise() } catch (error) { console.log('That did not go well.') }
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!