Closed Tejas12972 closed 3 years ago
This song crashes the process, idk why
Can you try this in discord-player@dev
?
I have exactly the same worries as him
Probably this is not the issue but, could it be because of the title has an file extension .mp4? Because when you reproduce local resource you can't reproduce it more than once unless you create a new resource every voiceStateUpdate or something like that
Probably this is not the issue but, could it be because of the title has an file extension .mp4?
No, because discord-player uses streams, not file name
probably it tries to play a destroyed queue or ended track
no child the music switch momentarily and sometimes the bot stops making music for no reason
Can you try this in
discord-player@dev
?
Same issue sometimes sometimes it works sometimes doesn't
@DevAndromeda There are two mistakes in my ticket, not just one. Moreover, the other person never answers his ticket.
me too
Error: Cannot play a resource that has already ended.
at AudioPlayer.play (/workspace/node_modules/discord-player/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:194:19)
at StreamDispatcher.<anonymous> (/workspace/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:172:30)
at Generator.next (<anonymous>)
at /workspace/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:8:71
at new Promise (<anonymous>)
at __awaiter (/workspace/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:4:12)
at StreamDispatcher.playStream (/workspace/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:165:16)
at Timeout._onTimeout (/workspace/node_modules/discord-player/dist/Structures/Queue.js:671:33)
at listOnTimeout (node:internal/timers:557:17)
at processTimers (node:internal/timers:500:7)
Error Status Code : 410
Error when playing any song, even using link or name discord.js : 13.0.1 discord-player : 5.0.2 node : 16.6.2
dev, pls fix
I am having the same issue.
It seems to be random, unable to easily duplicate. discord.js: 13.1.0 discord.js/voice: discord-player: 5.0.2 node: 16.6.2
Read this issue i think this will help u
ok, i fixed that
My old code :
const Discord = require('discord.js')
const { Player, QueryType, QueueRepeatMode } = require("discord-player");
module.exports = {
name: "play",
description: "play songs",
async run (client, message, args) {
console.log(`${message.createdAt} | ${message.author.tag} ${message.author} : ${message}`)
const player = client.player;
if (!message.member.voice.channel) return message.channel.send("❌ | **Bạn phải ở trong một kênh nói!**");
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(":x: | **Bạn phải ở cùng kênh nói với Bot!**");
const searchResult = await player
.search(args.join(" "), {
requestedBy: message.user,
searchEngine: QueryType.AUTO
})
.catch(() => {})
if (!searchResult || !searchResult.tracks.length) return message.channel.send("❌ | Không tìm thấy nhạc/video");
const queue = await player.createQueue(message.guild, {
metadata: message.channel
});
try {
if (!queue.connection) await queue.connect(message.member.voice.channel);
} catch {
queue.destroy();
return message.channel.send("❌ | Đã xảy ra lỗi khi tham gia kênh nói!");
} await message.channel.send(`⏱ | Đang tải ${searchResult.playlist ? "danh sách phát" : "bài nhạc"}...` );
searchResult.playlist ? queue.addTracks(searchResult.tracks) : queue.addTrack(searchResult.tracks[0]);
if (!queue.playing) await queue.play(searchResult);
if (!queue.playing) await queue.play();
}
}
so, I refer to the code of @PiousGaming, instead of ?
with :
I use if
with else
, change a few code locations...This is my new code :
const Discord = require('discord.js')
const { Player, QueryType, QueueRepeatMode } = require("discord-player");
module.exports = {
name: "play",
description: "play songs",
async run (client, message, args) {
console.log(`${message.createdAt} | ${message.author.tag} ${message.author} : ${message}`)
const player = client.player;
if (!message.member.voice.channel) return message.channel.send("❌ | **Bạn phải ở trong một kênh nói!**");
if (message.guild.me.voice.channel && message.member.voice.channel.id !== message.guild.me.voice.channel.id) return message.channel.send(":x: | **Bạn phải ở cùng kênh nói với Bot!**");
const queue = await player.createQueue(message.guild, {
metadata: message.channel
});
try {
if (!queue.connection) await queue.connect(message.member.voice.channel);
} catch {
queue.destroy();
return message.channel.send("❌ | Đã xảy ra lỗi khi tham gia kênh nói!");
}
const searchResult = await player.search(args.join(" "), {
requestedBy: message.user,
searchEngine: QueryType.AUTO
})
if (!searchResult || !searchResult.tracks.length) return message.channel.send("❌ | Không tìm thấy nhạc/video");
message.channel.send(`⏱ | Đang tải ${searchResult.playlist ? "danh sách phát" : "bài nhạc"}...` );
if (searchResult.playlist) {queue.addTracks(searchResult.tracks)} else {queue.addTrack(searchResult.tracks[0])};
if (!queue.playing) await queue.play();
}
}
I'm not sure where the code went wrong anymore, but it worked in the end 😆 . Hope it helps everyone
Error: Cannot play a resource that has already ended. at AudioPlayer.play (/home/container/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:194:19) at StreamDispatcher. (/home/container/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:172:30) at Generator.next () at /home/container/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:8:71 at new Promise () at __awaiter (/home/container/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:4:12) at StreamDispatcher.playStream (/home/container/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:165:16) at Timeout._onTimeout (/home/container/node_modules/discord-player/dist/Structures/Queue.js:671:33)
There is still no help for this misunderstood bug from everyone :(
Error: Cannot play a resource that has already ended. at AudioPlayer.play (/home/container/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:194:19) at StreamDispatcher. (/home/container/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:172:30) at Generator.next () at /home/container/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:8:71 at new Promise () at __awaiter (/home/container/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:4:12) at StreamDispatcher.playStream (/home/container/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:165:16) at Timeout._onTimeout (/home/container/node_modules/discord-player/dist/Structures/Queue.js:671:33)
There is still no help for this misunderstood bug from everyone :(
This bug is from discordjs/voice. Until they fixed it you have to wait for it
I tried playing your song https://www.youtube.com/watch?v=GhTYM9ZGnw0 with @discord-player/downloader attached and it played normally. Without @discord-player/downloader, it does not play the song though!
Seems to be the problem with ytdl-core I guess?
I tried playing your song https://www.youtube.com/watch?v=GhTYM9ZGnw0 with @discord-player/downloader attached and it played normally. Without @discord-player/downloader, it does not play the song though!
Seems to be the problem with ytdl-core I guess?
I have discord-player downloader but it also shows this err if play the track again
I will mark this as fixed on development
because I was able to reproduce this with yt cookies. Without using cookies, I used to get Error: status code 404
and with cookies, player seems to emit EPIPE
error and afterwards the process crashed saying Cannot play a resource that has already ended
. I have added a simple line that checks if the resource has already ended before playing and if so, it emits error event instead.
I will mark this as
fixed on development
because I was able to reproduce this with yt cookies. Without using cookies, I used to getError: status code 404
and with cookies, player seems to emitEPIPE
error and afterwards the process crashed sayingCannot play a resource that has already ended
. I have added a simple line that checks if the resource has already ended before playing and if so, it emits error event instead.
But when autoplay is enabled , sometimes it will play the same song that contains same resources and will trigger error event in this case and autoplay may not work properly.
[PlayerError] Cannot play a resource that has already ended. this error still occurs....OTL
[PlayerError] Cannot play a resource that has already ended. this error still occurs....OTL
🤔 Probably the case is that input stream gets through a transcoder layer where the stream is destroyed/ended somehow but still gets passed to audio player. Or maybe this is happening somewhere else? Could be ytdl itself
Usually this would just emit trackEnd event and eventually move to next track. AFAIK this usually happens to ytdl streams. Can you try play-dl and see if it works? I will do some investigation on this error because most of the times this doesnt happen to me in current version and it's really hard to debug because of that... LMK if there's a repro
Maybe we should add a manual check before creating a resource?
it’s usually the ytdl-core library that needs to be updated. otherwise it causes the process to crash
@Nitsugua38 Sorry but it doesn't work.
Describe the bug throw new Error('Cannot play a resource that has already ended.'); ^
Error: Cannot play a resource that has already ended. at AudioPlayer.play (/home/container/node_modules/@discordjs/voice/dist/audio/AudioPlayer.js:194:19) at StreamDispatcher. (/home/container/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:172:30)
at Generator.next ()
at /home/container/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:8:71
at new Promise ()
at __awaiter (/home/container/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:4:12)
at StreamDispatcher.playStream (/home/container/node_modules/discord-player/dist/VoiceInterface/StreamDispatcher.js:165:16)
at Timeout._onTimeout (/home/container/node_modules/discord-player/dist/Structures/Queue.js:671:33)
To Reproduce
Steps to reproduce the behavior:
playing this song https://www.youtube.com/watch?v=GhTYM9ZGnw0
Expected behavior Play the song
Please complete the following information: