Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (!message.member.voiceChannel) return message.channel.send(`Please connect to a voice channel ${message.author}`);
- //checks if the bot is already connected to a voice channel
- if (message.guild.me.voiceChannel) return message.channel.send("Sorry, the bot is already connected to a voice channel");
- //checks if the person put a url
- if (!args[0]) return message.channel.send(" Uh oh, something turned into a oof try again!");
- //validate info
- let validate = await ytdl.validateURL(args[0]);
- //checks validation
- if (!validate) return message.channel.send("Uhhhh wa happend? Try again please");
- //fetches video information
- let info = await ytdl.getInfo(args[0]);
- //stores authors guild channels
- let connection = await message.member.voiceChannel.join();
- //plays the song with url
- let dispatcher = await connection.playStream(ytdl(args[0], { filter: `audioonly`}));
- //song now playing
- message.channel.send(`Now playing: ${info.title}`);
Add Comment
Please, Sign In to add comment