Implement functions and variables to functions file

This commit is contained in:
rhearmas 2020-02-13 09:47:11 -08:00
parent f08b46c8ab
commit 704def74a5
2 changed files with 53 additions and 52 deletions

View File

@ -1,19 +1,4 @@
function play(connection, message) {
var server = servers[message.guild.id];
server.dispatcher = connection.playStream(ytdl(server.queue[0],{filter: "audioonly"}));
server.queue.shift();
server.dispatcher.on("end", function() {
if(server.queue[0]) {
play(connection, message);
} else {
connection.disconnect();
}
})
};
const ytdl = require("ytdl-core");
var servers = {};
exports.run = async (client, message, args, level) => {
if(!args[1] || args[1].startsWith("https://")) return (await message.reply("you need to provide a valid URL!")).delete(5000).catch(() => { });
@ -27,7 +12,7 @@ exports.run = async (client, message, args, level) => {
server.queue.push(args[1]);
if(!message.guild.voiceConnection) message.member.voiceChannel.join().then(function(connection) {
play(connection, message);
client.play(connection, message);
})
};

View File

@ -351,4 +351,20 @@ module.exports = (client) => {
client.Logger.error(error);
});
}
var servers = {};
client.play = (connection, message) => {
var server = servers[message.guild.id];
server.dispatcher = connection.playStream(ytdl(server.queue[0],{filter: "audioonly"}));
server.queue.shift();
server.dispatcher.on("end", function() {
if(server.queue[0]) {
play(connection, message);
} else {
connection.disconnect();
}
})
};
};