Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

141
Vistas
El bot de música DiscordJS se desconecta inmediatamente después de comenzar a reproducir la canción

Intento reproducir una URL de Youtube, pero cuando comienza a reproducirse, se detiene después de 1 segundo. Los archivos mp3 funcionan bien, simplemente no funciona cuando intento reproducir las URL de Youtube.

Aquí está mi código:

 case 'play': { const Channel = ['903334978199388271']; for (const channelId of Channel) { joinChannel(channelId); } function joinChannel(channelId) { Client.channels .fetch(channelId) .then((channel) => { const VoiceConnection = joinVoiceChannel({ channelId: channel.id, guildId: channel.guild.id, adapterCreator: channel.guild.voiceAdapterCreator, }); const player = createAudioPlayer(); VoiceConnection.subscribe(player); player.play( createAudioResource( ytdl('https://www.youtube.com/watch?v=sPPsOmQh76A'), ), ); }) .catch(console.error); } } break;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Tuve el mismo problema antes, el problema es ytdl-core , por lo que puede usar ytdl-core-discord su lugar. Aquí hay un ejemplo:

 const { Client, Intents, MessageEmbed } = require('discord.js') const ytdl = require('ytdl-core-discord') const { joinVoiceChannel, createAudioPlayer, createAudioResource, StreamType } = require('@discordjs/voice') const client = new Client({ intents: [ Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MEMBERS, Intents.FLAGS.GUILD_MESSAGES, Intents.FLAGS.GUILD_VOICE_STATES /// <= Don't miss this :) ] }); var prefix = '!' client.on('ready', async () => { console.log('Client is Ready...'); }); client.on('messageCreate', async (message) => { if (message.content.trim().toLocaleLowerCase() === prefix + 'play') { const channel = client.channels.cache.get('Channel ID Here') const connection = joinVoiceChannel({ channelId: channel.id, guildId: channel.guildId, adapterCreator: channel.guild.voiceAdapterCreator }); const player = createAudioPlayer(); const resource = createAudioResource(await ytdl('https://www.youtube.com/watch?v=sPPsOmQh76A'), { inputType: StreamType.Opus }); player.play(resource); connection.subscribe(player); } }); client.login('Bot Token Here!');
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda