Discord Bot Youtube Search, Wait For Answer Of Asynchronous Function
I have built a discord but using javascript I've got one command where I want the ability to search for a youtube video and play the first result in a voice channel. I'm using the
Solution 1:
You can run that in an async
function:
voiceChannel.join().then(async connection => {
let url = await searchYouTubeAsync(args);
let stream = ytdl(url, { filter: 'audioonly' });
let dispatcher = connection.playStream(stream);
dispatcher.on('end', () => voiceChannel.leave());
isReady = true;
})
Post a Comment for "Discord Bot Youtube Search, Wait For Answer Of Asynchronous Function"