From dddaeba8e3b0106b6fb3229a3d39b32e24ff9441 Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Thu, 28 May 2020 17:52:15 +1000 Subject: [PATCH] fixmusic can be used by users, invidious issues --- src/commands/fixmusic.js | 53 ++++++++++++++++++++++++++++++++++------ src/commands/stop.js | 1 + src/modules/music.js | 8 ++++-- 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/src/commands/fixmusic.js b/src/commands/fixmusic.js index 387aa9f..e7c1171 100644 --- a/src/commands/fixmusic.js +++ b/src/commands/fixmusic.js @@ -2,23 +2,60 @@ const { getGuild } = require('../modules/music') module.exports.run = async (client, message, args, level) =>{ guild = getGuild(message.guild.id) - guild.queue = [] - guild.playing = false - guild.paused = false - guild.skippers = [] + const lvl = client.config.permLevels.find(l => l.level === level) - if (guild.dispatcher) { - guild.dispatcher.end('silent') + if (lvl >= 1) { + guild.queue = [] + guild.playing = false + guild.paused = false + guild.skippers = [] + guild.fixers = [] + + if (guild.dispatcher) { + guild.dispatcher.end('silent') + } + + message.channel.send( + '<:success:466995111885144095> Music has been fixed!' + ) + + return } - message.channel.send('<:success:466995111885144095> Music has been fixed (hopefully)') + if (guild.fixers.indexOf(message.author.id) === -1) { + guild.fixers.push(message.author.id) + + if (guild.fixers.length >= Math.ceil(vc.members.filter(member => !member.user.bot).size / 2)) { + guild.queue = [] + guild.playing = false + guild.paused = false + guild.skippers = [] + guild.fixers = [] + + if (guild.dispatcher) { + guild.dispatcher.end('silent') + } + + message.channel.send( + '<:success:466995111885144095> Music has been fixed!' + ) + } else { + message.channel.send( + `<:success:466995111885144095> Your vote has been acknowledged! **${guild.fixers.length + '/' + Math.ceil(vc.members.filter(member => !member.user.bot).size / 2)}**` + ) + }; + } else { + message.channel.send( + '<:denied:466995195150336020> You cannot vote twice!' + ) + } } exports.conf = { enabled: true, guildOnly: true, aliases: [], - permLevel: "Moderator", + permLevel: "User", requiredPerms: [] }; diff --git a/src/commands/stop.js b/src/commands/stop.js index b36b2a1..4f732ff 100644 --- a/src/commands/stop.js +++ b/src/commands/stop.js @@ -11,6 +11,7 @@ exports.run = async (client, message) => { guild.playing = false guild.paused = false guild.skippers = [] + guild.fixers = [] message.channel.send('<:success:466995111885144095> Playback stopped!') }; diff --git a/src/modules/music.js b/src/modules/music.js index e7f30eb..2eb3b5d 100644 --- a/src/modules/music.js +++ b/src/modules/music.js @@ -28,6 +28,7 @@ exports.getGuild = function (id) { guild.paused = false guild.dispatcher = null guild.skippers = [] + guild.fixers = [] exports.queue[id] = guild } @@ -102,6 +103,7 @@ exports.play = async function (client, message, query, playNext, ignoreQueue) { guild.playing = false guild.paused = false guild.skippers = [] + guild.fixers = [] // music not playing, something is in queue } else if (!guild.playing && !guild.dispatcher && guild.queue.length > 0) { guild.queue = [] @@ -200,8 +202,9 @@ exports.play = async function (client, message, query, playNext, ignoreQueue) { guild.queue.pop() } - client.logger.error(err) - return message.channel.send(`<:error:466995152976871434> An error has occured! If this issue persists, please contact my developers with this:\n\`${err}\``) + client.logger.error('(YT API change, disregard) ' + err) + // return message.channel.send(`<:error:466995152976871434> An error has occured! If this issue persists, please contact my developers with this:\n\`${err}\``) + return message.channel.send('<:error:466995152976871434> YouTube have made changes to their site that break Woomy\'s music module. An announcement will be made in the development server when this issue is resolved.') } guild.dispatcher.setVolume(0.25) @@ -219,6 +222,7 @@ exports.play = async function (client, message, query, playNext, ignoreQueue) { guild.playing = false guild.paused = false guild.skippers = [] + guild.fixers = [] connection.disconnect() }