From 6bf3ffdfc9a9e7244fa2f45a041acf761d3312ba Mon Sep 17 00:00:00 2001 From: MatteZ02 <47610069+MatteZ02@users.noreply.github.com> Date: Wed, 4 Mar 2020 22:27:14 +0200 Subject: [PATCH] voiceStateUpdate --- events/dispatcher/finish.js | 7 ++----- struct/funcs/handleVideo.js | 2 ++ struct/funcs/play.js | 4 +--- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/events/dispatcher/finish.js b/events/dispatcher/finish.js index ede590d4..ef2e1bf0 100644 --- a/events/dispatcher/finish.js +++ b/events/dispatcher/finish.js @@ -1,17 +1,14 @@ module.exports = async function (client, reason, guild) { const serverQueue = client.queue.get(guild.id); serverQueue.playing = false; - if (reason === "Stream is not generating quickly enough.") { - console.log("Song ended"); - } else if (reason === "seek") { + if (reason === "seek") { return; - } else { - console.log(reason); } if (!serverQueue.songLooping) { if (serverQueue.looping) { serverQueue.songs.push(serverQueue.songs[0]); } + serverQueue.votes = 0; serverQueue.voters = []; serverQueue.songs.shift(); diff --git a/struct/funcs/handleVideo.js b/struct/funcs/handleVideo.js index ce366697..8509c9ad 100644 --- a/struct/funcs/handleVideo.js +++ b/struct/funcs/handleVideo.js @@ -16,12 +16,14 @@ module.exports = async function (video, msg, voiceChannel, client, playlist = fa } const construct = require("../config/queueConfig.js"); + construct.textChannel = msg.channel; construct.voiceChannel = voiceChannel; construct.volume = client.global.db.guilds[msg.guild.id].defaultVolume; construct.bass = client.global.db.guilds[msg.guild.id].bass; construct.songs.push(song); + client.queue.set(msg.guild.id, construct); try { diff --git a/struct/funcs/play.js b/struct/funcs/play.js index 954d237f..e15dd76c 100644 --- a/struct/funcs/play.js +++ b/struct/funcs/play.js @@ -5,15 +5,13 @@ module.exports = async function (guild, song, client, seek, play) { const serverQueue = client.queue.get(guild.id); if (!song) { - console.log('No song') serverQueue.voiceChannel.leave(); client.queue.delete(guild.id); return; } - const dispatcher = serverQueue.connection .play(await ytdl(song.url, { filter: "audio", highWaterMark: 1 << 25, volume: false }), { seek: seek, bitrate: 1024, passes: 10, volume: 1, bassboost: serverQueue.bass }) - .on("end", () => { + .on("finish", () => { client.dispatcher.finish(client, serverQueue.endReason, guild); }); dispatcher.on('start', () => {