I wrote a discord bot. "o" is first letter of play. "atla" is skip. When I wrote -o MUSIC_NAME, music is adding queue and starting to play. And when I write again, just adding queue. Everything is okay still here. When I wrote -atla. It's also working perfectly. But when I allow to changing auto music itself, it's changing music automatically. But problem is here. The end of the last music not working else if (list.length === 0) block in endHandler function. How can I fix that? Thanks for your attention.
-------Playing when command = o --------------------------------------------
await list.push(mObj);
message.channel.send(`"${mObj.name}" sıraya eklendi.`);
if (list.length === 1 && pStatus === false) {
pStatus = true;
cMusic = list.shift();
dispatcher = connection.play(ytdl(`${cMusic.link}`, { filter: 'audioonly' }));
dispatcher.on('start', () => {
message.reply(`${cMusic.name} çalıyorum.`);
});
endHandler();
}
--------------Playing when command = atla -------------------------------
if (command === 'atla') {
if (message.member.voice.channel) {
dispatcher.pause();
pStatus = false;
if (list.length >= 1) {
cMusic = list.shift();
dispatcher = connection.play(ytdl(`${cMusic.link}`, { filter: 'audioonly' }));
dispatcher.on('start', () => {
message.reply(`${cMusic.name} çalıyorum.`);
});
endHandler();
} else {
message.reply("Liste sonlandı.");
}
} else {
message.reply("Önce sesli bir kanala katılmalısın.")
}
}
const endHandler = () => {
dispatcher.on('finish', () => {
pStatus = false;
if (list.length >= 1) {
message.reply("listede birden çok link var.")
cMusic = list.shift();
dispatcher = connection.play(ytdl(`${cMusic.link}`, { filter: 'audioonly' }));
dispatcher.on('start', () => {
message.reply(`${cMusic.name} çalıyorum.`);
pStatus = true;
});
} else if (list.length === 0) {
message.reply("Liste sonlandı.")
/* Not working this part. */
}
});
}
Aucun commentaire:
Enregistrer un commentaire