• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

195
Views
ReferenceError: la voz no está definida discord.js

Estoy tratando de hacer un pequeño Music Bot en Discord.js v16.6 que pueda reproducir archivos locales, pero recibí el error:

ReferenceError: la voz no está definida

No entiendo por qué la voz no está definida. ¿Cómo puedo solucionar este error?

Aquí está la parte de mi código:

 if( isReady && startsWithInList(message.content, settings.commandPlay) ) { isReady = false; const args = message.content.slice(10).trim().split(' '); if( args.length != 1 || !args[0] || args[0] === "" ) { return message.channel.send(settings.warningPlayArgsSentence); } var voiceChannel = message.member.voice.channel; voice.channel.join().then( connection => { const dispatcher = connection.play(settings.filesDir+args[0]+'.mp3') dispatcher.on('finish', () => { voiceChannel.leave(); isReady = true; }) }); }

* No puedo proporcionar el código completo porque stackoverflow no lo permitirá

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

0

Discord.js solo sube a la versión v13.4 al momento de escribir esto. El código aquí parece que es para la versión v12. Supongo que estás en Node.js v16.6.

Con respecto al problema real, estás haciendo referencia a una voice variable que no existe. ver esta línea

 voice.channel.join().then( connection => {

Supongo que solo querías hacer referencia a la variable creada directamente antes de esta línea.

 if( isReady && startsWithInList(message.content, settings.commandPlay) ) { isReady = false; const args = message.content.slice(10).trim().split(' '); if( args.length != 1 || !args[0] || args[0] === "" ) { return message.channel.send(settings.warningPlayArgsSentence); } var voiceChannel = message.member.voice.channel; // See below for the change voiceChannel.join().then( connection => { const dispatcher = connection.play(settings.filesDir+args[0]+'.mp3') dispatcher.on('finish', () => { voiceChannel.leave(); isReady = true; }) }); }
about 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error