-
-
Notifications
You must be signed in to change notification settings - Fork 190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] Leaves channel as soon as the bot starts to play any music - or will skip the song then leave. #848
Comments
I'm running to the same issue when i restart my bot and try to play some music , it joins the vc and then leaves... Not sure if this is a bug. |
I think it's |
I was facing this issue too but was able to get around it by adding these ytdl options to the player. ytdlOptions: {
quality: 'highestaudio',
highWaterMark: 1 << 25,
}, Haven't tested this extensively, but it seems to stop the bot from stopping after playing for a few seconds. [Edit]: Inspired by the config values in MusicBot by ZerioDev |
I also have this problem, please help me |
This configuration works perfectly, in the same way, if you have ytdlOptions: {
dlChunkSize: 0,
}, |
Had same problem😢, but not gonna fix now, labs + exam overhead.. i didn't prep for any! |
Node Version: 16.9.1 |
I still have the same problem... |
**This seems to work ** try it out 👍🏻 |
those of you coming from music-bot const queue = await player.createQueue(message.guild, {
ytdlOptions: {
quality: "highest",
filter: "audioonly",
highWaterMark: 1 << 25,
dlChunkSize: 0,
},
metadata: message.channel
});```
|
Ok so @DevAndromeda said that we can now handle streams ourselves by installing the dev version I used play-dl to handle the streams, and it has solved the problem for me. First off, I initialize the player like this client.player = new Player(client, {
ytdlOptions: {
quality: 'highestaudio',
hightWaterMark: 1 << 25,
}
}); And when I'm creating a queue: const playdl = require('play-dl');
const queue = await client.player.createQueue(guild, {
metadata: channel,
async onBeforeCreateStream(track, source, _queue) {
// console.log({track: track, source: source});
if (isSpotify(track.url)) {
if (playdl.is_expired()) await playdl.refreshToken();
let spotify_data = await playdl.spotify(track.url);
let yt_query = `${spotify_data.name} by `;
spotify_data.artists.forEach((key) => yt_query += key.name + ' ');
console.log(`[${guild.name}] Spotify -> YouTube: ${yt_query}`);
let search_yt = await playdl.search(yt_query, { limit: 1 });
return (await playdl.stream(search_yt[0].url)).stream;
} else {
return (await playdl.stream(track.url)).stream;
}
}
}); I know I could have used function isSpotify (url) {
let re = new RegExp('^(spotify:|https://[a-z]+\.spotify\.com/)');
return re.test(url);
} If you would like to try this method with |
const queue = await client.player.createQueue(message.guild,{ metadata: { channel: message.channel },
async onBeforeCreateStream(track, source, _queue) {
if (track.url.includes("youtube.com")) {
// play directly if it's a youtube track
return (await playdl.stream(track.url)).stream;
}
else {
// search for the track on youtube with the track author & title using playdl.search()
// i added "lyric" to the search query to avoid playing music video streams
return (await playdl.stream(await playdl.search(`${track.author} ${track.title} lyric`, { limit : 1, source : { youtube : "video" } }).then(x => x[0].url))).stream;
}
}
}); |
@nizeic My code currently is the following: async onBeforeCreateStream(track, source, _queue) {
// console.log({track: track, source: source});
try {
if (isSpotify(track.url)) {
// Spotify
if (play_dl.is_expired()) await play_dl.refreshToken();
let spotify_data = await play_dl.spotify(track.url);
let yt_query = `${spotify_data.name} by `;
spotify_data.artists.forEach((key) => yt_query += key.name + ' ');
console.log(`[${guild.name}] Spotify -> YouTube: ${yt_query}`);
let search_yt = await play_dl.search(yt_query, { limit: 1 });
return (await play_dl.stream(search_yt[0].url)).stream;
} else {
// YouTube & SoundCloud
return (await play_dl.stream(track.url)).stream;
}
} catch (err) {
console.error(`[${guild.name}] Error: onBeforeCreateStream() -> ${err.message}`);
}
} I'm actually checking if the track comes from spotify, then it'll search for the track name and artists' names and play it via youtube. Otherwise, if the track comes from either youtube or soundcloud it'll just play the stream. This implementation currently works perfectly for me. The only thing that will not work is soundcloud private links, but I have not had the time yet to look into why this is happening. About using regex, it's just my way of doing things 😋 A YouTube link doesn't necessarily include We're kinda doing the same thing, just different implementation. |
my bad. i thought play-dl could only play directly from youtube |
You can just check the source parameter. Using |
here is a lil other fix that I have found |
thanks man saved my day |
Hello, you can use some stable stream sources/alternatives of |
Describe the bug
Leaves channel as soon as the bot starts to play any music - or will skip the song then leave.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Shouldn't do this
Screenshots
Please complete the following information:
v 16.11 - Discord Player v MOST RECENT - DJS MOST RECENT
Additional context
The text was updated successfully, but these errors were encountered: