Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const Discord = require ("discord.js");
- const commando = require("discord.js-commando");
- const ytdl = require("ytdl-core");
- exports.run = async(client,message,args,ops)=>
- {
- //const serverQueue = queue.get(message.guild.id);
- if (!message.member.voiceChannel) return message.channel.send("please connect to a channel");
- if(message.guild.me.voiceChannel) return message.channel.send('sorry im in ');
- if(!args[0] )return message.channel.send('please put in url');
- let validation = await ytdl.validateURL(args[0]);
- if(!validation) return message.channel.send("sorry the url isnt right");
- let data = ops.active.get(message.guild.id) || {};
- if(!data.connection) data.conection = await message.memeber.voiceChannel.join();
- if(!data.queue) data.queue = [];
- data.guildID= message.guild.id;
- data.queue.push({
- songTitle: info.title,
- reuester: message.author.tag,
- url: args[0],
- announceChannel: message.channel.id
- });
- if(!data.dispatcher) play(client,ops,data );
- else {
- message.channel.send(`added to the QUeue: ${info.title} | requested by ${message.author.id}`);
- }
- ops.active.set(message.guild.id, data);
- }
- async function play(client, ops, data)
- {
- client.channels.get(data.queue[0].announceChannel).send(`now playing: ${data.queue[0]} | request by ${data.queue[0].requester}`);
- data.dispatcher - await data.connection.play(ytdl(data.queue[0].url, {filter: 'auioonly '}));
- data.dispater.once('finish', function(){
- finish(cleint,ops,this);
- })
- }
- function finish(client,ops,dispatcher)
- {
- let fetched = ops.active.get(dispatcher.guildID);
- fetched.queue.shift();
- if (fetched.queue.lenghth >0)
- {
- ops.active.set(dispatcher.guildID,featched);
- play(client,ops,fetched);
- }
- else
- {
- ops.actie.delete(dispatcher.guildID);
- let vc = client.guilfd.get(dispatcher.guildID).me.voiceChannel;
- if (vc) vc.leave();
- }
- }
- module.exports.help = {
- name:"joins"
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement