Advertisement
HelloDearSir

Untitled

Jan 5th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 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,ops)=>
  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.  
  18. let validation = await ytdl.validateURL(args[0]);
  19.  
  20. if(!validation) return message.channel.send("sorry the url isnt right");
  21.  
  22.  
  23. let data = ops.active.get(message.guild.id) || {};
  24.  
  25. if(!data.connection) data.conection = await message.memeber.voiceChannel.join();
  26. if(!data.queue) data.queue = [];
  27. data.guildID= message.guild.id;
  28.  
  29. data.queue.push({
  30. songTitle: info.title,
  31. reuester: message.author.tag,
  32. url: args[0],
  33. announceChannel: message.channel.id
  34.  
  35. });
  36.  
  37. if(!data.dispatcher) play(client,ops,data );
  38. else {
  39. message.channel.send(`added to the QUeue: ${info.title} | requested by ${message.author.id}`);
  40. }
  41.  
  42. ops.active.set(message.guild.id, data);
  43.  
  44.  
  45.  
  46.  
  47. }
  48. async function play(client, ops, data)
  49. {
  50. client.channels.get(data.queue[0].announceChannel).send(`now playing: ${data.queue[0]} | request by ${data.queue[0].requester}`);
  51. data.dispatcher - await data.connection.play(ytdl(data.queue[0].url, {filter: 'auioonly '}));
  52. data.dispater.once('finish', function(){
  53. finish(cleint,ops,this);
  54. })
  55. }
  56.  
  57. function finish(client,ops,dispatcher)
  58. {
  59. let fetched = ops.active.get(dispatcher.guildID);
  60.  
  61. fetched.queue.shift();
  62.  
  63. if (fetched.queue.lenghth >0)
  64. {
  65. ops.active.set(dispatcher.guildID,featched);
  66.  
  67. play(client,ops,fetched);
  68. }
  69. else
  70. {
  71. ops.actie.delete(dispatcher.guildID);
  72. let vc = client.guilfd.get(dispatcher.guildID).me.voiceChannel;
  73. if (vc) vc.leave();
  74. }
  75. }
  76.  
  77. module.exports.help = {
  78.  
  79. name:"joins"
  80.  
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement