How To Make Discord Bot Play YouTube URL

I’m new to this and I wonder if there’s a way I can make my bot play specific YouTube URL so when I type s1 the bot join the room and play that URL

 if (message.content == "s1") {
     if (! return message.reply("You have to be in a VoiceChannel"); => {"").on("finish", () => 
     }).catch(e => console.log(e))


You need to use a package called ytdl to do this:

in terminal you do npm install [email protected]

then add const ytdl = require('ytdl-core'); to the top of your js file.

then you need to change"").on("finish", () =>

to"")).on("finish", () =>

Leave a Reply

Your email address will not be published. Required fields are marked *