Advertisement
HelloDearSir

Untitled

Jan 5th, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. const Discord = require ("discord.js");
  2. const commando = require("discord.js-commando");
  3. const ytdl = require("ytdl-core");
  4.  
  5.  
  6.  
  7. exports.run = async(client,message,args)=>
  8. {
  9.  
  10. //const serverQueue = queue.get(message.guild.id);
  11.  
  12. if (!message.member.voiceChannel) return message.channel.send("please connect to a channel");
  13.  
  14. if(message.guild.me.voiceChannel) return message.channel.send('sorry im in ');
  15.  
  16. if(!args[0] )return message.channel.send('please put in url');
  17. //validating the url of the youtube.
  18. /*if (!serverQueue)
  19. {
  20. const queueconstruct = {
  21. textChannel: messge.channel,
  22. voiceChannel: voiceChannel,
  23. connect: null,
  24. songs: [],
  25. Playing : true
  26. };
  27. queue.set(message.guild.id, queueconstruct);
  28. }*/
  29. let validation = await ytdl.validateURL(args[0]);
  30.  
  31. if(!validation) return message.channel.send("sorry the url isnt right");
  32.  
  33. let infor = await ytdl.getInfo(args[0]);
  34. //
  35. let connection = await message.member.voiceChannel.join();
  36. //when
  37. const dispatcher = await connection.playStream(ytdl(args[0], {filter: 'audioonly'}))
  38. .on ('end', () =>{
  39. console.log('song ended');
  40. voiceChannel.disconnect();
  41.  
  42. })
  43.  
  44. .on('err', error => {
  45. console.console(err);
  46.  
  47. });
  48.  
  49.  
  50. dispatcher.setVolumeLogarithmic(5 / 5);
  51.  
  52. message.channel.send(`now playing: ${infor.title}`);
  53.  
  54.  
  55.  
  56.  
  57. }
  58. module.exports.help = {
  59.  
  60. name:"joins"
  61.  
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement