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

227
Views
Me encontré con un error al hacer que el bot de música se uniera a VC
const ytdl = require('ytdl-core'); const ytSearch = require('yt-search'); module.exports = { name: 'play', description: "plays music in voice chat", async execute(message, args, Discord){ const voiceChannel = message.member.voice.channel; if (!voiceChannel) return message.channel.send('You need to be in a voice channel to listen to music!'); const permissions = voiceChannel.permissionsFor(message.client.user); if (!permissions.has('CONNECT')) return message.reply("You don't have the correct permissions to request music!"); if (!permissions.has('SPEAK')) return message.reply("You don't have the correct permissions to request music!"); if (!args.length) return message.channel.send("You Can't Request for no Music Silly >_<"); const connection = await voiceChannel.join(); const videoFinder = async (query) => { const videoResult = await ytSearch(query); return (videoResult.videos.length > 1) ? videoResult.videos[0] : null; } const video = await videoFinder(args.join(' ')); if(video){ const stream = ytdl(video.url, {filter: 'audioonly'}); connection.play(stream, {seek: 0, volume: 1}) .on('finish', () =>{ voiceChannel.leave(); }); await message.reply(`:Thumbsup: Now Playing >>>${video.title}<<<`) } else { message.reply('No Video Results Found :('); } } }

Mi mensaje de error es const connection = await voiceChannel.join();

TypeError: voiceChannel.join no es una función

Si alguno de ustedes tiene una sugerencia que pueda funcionar, no dude en editarla. También puede detectar solo si alguien está en el chat de voz al inicio del bot, por lo que si está en el chat de voz al inicio del bot, envía el mensaje de chat de voz mientras está dentro y fuera del chat de voz.

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

0

Durante la transición de discord.js v12 - v13, encontramos un cambio importante que es cambiar a @discordjs/voice una biblioteca separada para que la voz se reproduzca con discord.js, ahora, como se sugiere en el comentario aquí, veo que está usando la mayoría última versión de discord.js donde el método VoiceChannel#join ya no existe. Tienes que proponer los siguientes cambios:

  • Instale @discordjs/voice usando npm install @discordjs/voice
  • Debe establecer una voiceConnection de voz y, además, crear una instancia de AudioPlayer y seguir adelante y llamar al método AudioPlayer#subscribe a este reproductor, tendría que hacer algunas adiciones básicas para el mismo que se muestran a continuación:
 const { joinVoiceChannel, createAudioPlayer, createAudioResource } = require('@discordjs/voice'); const connection = joinVoiceChannel({ channelId: message.member.voice.channel.id, guildId: message.guild.id, adapterCreator: message.guild.voiceAdapterCreator, }); const stream = ytdl(video.url, { filter: "audioonly" }); const player = createAudioPlayer(); const resource = createAudioResource(stream); async function play() { await player.play(resource); connection.subscribe(player); }

Simplemente lo hicieron demasiado complejo para que los principiantes lo comprendieran, ¡así que no se preocupen! Si sientes que te estás cansando demasiado, siempre puedes bajar a una versión más baja como esta:

 npm uninstall discord.js npm install discord.js@12.5.3

Bienvenido a stackoverflow 😄

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!