0
My doubt is this, I have a code that he bot connects to the voice channel of Discord when user command "!! play url_video_youtube". When again typed command is incremented the array "listMusic". My doubt is how I do when finishing current music it advances to next.
In "Dispatcher.on('Finish') I can know when you finished the song, I just don’t know how to play next song according to array item.
async onPlayMusic (message:Message, url:string){
listMusic.push(url);
const voiceChannel = message?.member?.voice.channel;
if (!voiceChannel) {
return message.reply('precisa está em canal de voz!');
}
[0,1]
voiceChannel.join().then(connection => {
const stream = ytdl(url, { filter: 'audioonly' });
const dispatcher = connection.play(stream);
dispatcher.on('finish', () => {
let musics = listMusic.length;
if(musics > 1){
listMusic[listMusic.length-1];
}
//voiceChannel.leave()
});
});
},
Thanks. I’m going to a study in callback found very interesting.
– Max wilson