From a31dc025688578f47599b5660302ff0cefb8591d Mon Sep 17 00:00:00 2001 From: mudkipscience Date: Wed, 29 Apr 2020 21:00:11 +1000 Subject: [PATCH] begin polishing up music modules --- commands/movehere.js | 35 +++++++---------------------------- commands/movesong.js | 20 ++++++-------------- 2 files changed, 13 insertions(+), 42 deletions(-) diff --git a/commands/movehere.js b/commands/movehere.js index 38636aa..eb2d4cd 100644 --- a/commands/movehere.js +++ b/commands/movehere.js @@ -4,15 +4,15 @@ exports.conf = { enabled: true, guildOnly: true, aliases: [], - permLevel: 'User ', + permLevel: 'User', requiredPerms: ['CONNECT', 'SPEAK'], - cooldown: 10000 + cooldown: 2000 } exports.help = { name: 'movehere', category: 'Music', - description: 'Moves the bot into your voice channel and/or text channel.', + description: 'Moves music related messages to the channel the this command is ran in.', usage: 'movehere', parameters: '' } @@ -26,32 +26,11 @@ exports.run = async (client, message, args, level, data) => { return message.channel.send('<:error:466995152976871434> Nothing is playing.') } - let textChannelChanged = false - let voiceChannelChanged = false - - // change text channel - if (guild.channel.id !== message.channel.id) { - guild.channel = message.channel - - textChannelChanged = true + if (guild.channel.id === message.channel.id) { + return message.channel.send('<:error:466995152976871434> Music messages are already being sent to this channel.') } - // move to another voice channel - if (message.member.voice.channel && guild.voiceChannel && (message.member.voice.channel !== guild.voiceChannel.id)) { - guild.voiceChannel.leave() - guild.voiceChannel = message.member.voice.channel - guild.voiceChannel.join() - voiceChannelChanged = true - } + guild.channel = message.channel - // response - if (textChannelChanged && voiceChannelChanged) { - return message.channel.send('<:success:466995111885144095> Music playback moved to your voice channel and music messages to your text channel.') - } else if (textChannelChanged) { - return message.channel.send('<:success:466995111885144095> Music module will send messages to your text channel.') - } else if (voiceChannelChanged) { - return message.channel.send('<:success:466995111885144095> Music playback moved to your voice channel.') - } else { - return message.channel.send('<:error:466995152976871434> Music is already playing in your voice channel!') - } + message.channel.send('<:success:466995111885144095> Music messages will now be sent to this channel.') } diff --git a/commands/movesong.js b/commands/movesong.js index c56d95e..01807f0 100644 --- a/commands/movesong.js +++ b/commands/movesong.js @@ -37,27 +37,19 @@ module.exports.run = (client, message, args, level) => { const newPosition = +args[1] if (isNaN(oldPosition) === true) { - return message.channel.send('That isn\'t a number! You need to tell me the songs position in the queue (1, 2, etc.)') + return message.channel.send('<:error:466995152976871434> That isn\'t a number! You need to tell me the songs position in the queue (1, 2, etc.)') } if (isNaN(newPosition) === true) { - return message.channel.send('That isn\'t a number! You need to tell me the songs position in the queue (1, 2, etc.)') + return message.channel.send('<:error:466995152976871434> That isn\'t a number! You need to tell me the songs position in the queue (1, 2, etc.)') } - if (oldPosition < 1) { - return message.channel.send('This number is too low!') + if (oldPosition < 1 || oldPosition >= queue.length) { + return message.channel.send('<:error:466995152976871434> Invalid song ID.') } - if (newPosition < 1) { - return message.channel.send('This number is too low!') - } - - if (oldPosition >= queue.length) { - return message.channel.send('This number is too high!') - } - - if (newPosition >= queue.length) { - return message.channel.send('This number is too high!') + if (newPosition < 1 || newPosition >= queue.length) { + return message.channel.send('<:error:466995152976871434> Invalid song ID.') } const songName = queue[oldPosition].video.title