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

144
Views
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 answers
Answer question

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 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!