Hice un bot que reproduce música. Actualicé a NodeJS v16.6.1 y voiceChannel.join ya no funciona. Ya intenté usar const { voiceChannel } = require('@discord.js/voice');
pero solo dice módulo no encontrado. Código:
const ytdl = require("ytdl-core"); const ytSearch = require("yt-search"); module.exports = { name: 'play', description: 'Joins and plays a video from youtube', async execute(message, args) { const voiceChannel = message.member.voice.channel; if (!voiceChannel) return message.channel.send('You need to be in a channel to execute this command'); const permissions = voiceChannel.permissionsFor(message.client.user); if (!permissions.has('CONNECT')) return message.channel.send('You dont have the neccesary permissions'); if (!permissions.has("SPEAK")) return message.channel.send('You dont have the neccesary permissions'); if (!args.length) return message.channel.send('Define Video'); 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(`Now Playing **${video.title}**`) } else { message.channel.send('No videos found'); } } }```
Como dice el error, voiceChannel#join
no es, de hecho, una función. Si bien existía en Discord.js v12, que supongo que estaba usando antes de actualizar su versión de Node.js, tenga en cuenta que no se encuentra en ninguna parte de la documentación de Discord.js v13 en VoiceChannel
. En su lugar, debe migrar a @discordjs/voice
, cuya funciónjoinVoiceChannel
se puede usar como reemplazo.