From d901ee467217d9a4d8a044945caf6d1efcf8e1ae Mon Sep 17 00:00:00 2001 From: Josh Creek Date: Sat, 21 Nov 2020 14:26:11 +0000 Subject: [PATCH] fix(*): Hand edge cases for the start command --- index.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 325f40d..ef544ec 100644 --- a/index.js +++ b/index.js @@ -136,9 +136,11 @@ function checkQueue(message) { makeTempChannel(message, adventureMessage); - // Clear the queue + // Clear the queue and votes playerQueue = []; logger.log('info', 'Emptied queue'); + playerVotes = []; + logger.log('info', 'Emptied votes'); } else if (playerQueue.length === 0) { message.channel.send('The queue is empty :('); @@ -328,6 +330,9 @@ client.on('message', function (message) { if(playerQueue.length == 0) { message.channel.send(`You can only vote to start an adventure early if there is a queue. You can start a queue by using the command ${config.prefix}help`); } + else if (!playerQueue.includes(message.author)) { + message.channel.send(`You can only vote to start an adventure early if you are in the queue. You can join the queue by using the command ${config.prefix}q`); + } else if(playerVotes.length == 0) { // First player to vote playerVotes.push(message.author); @@ -377,10 +382,11 @@ client.on('message', function (message) { message.channel.send(`The queue is already empty...`); logger.log('info', `${message.author.username} attempted to clear the queue but it was already empty.`); } - else { + else { playerQueue = []; + playerVotes = []; message.channel.send(`The queue has been cleared!`); - logger.log('info', `${message.author.username} cleared the queue.`); + logger.log('info', `${message.author.username} cleared the queue and the votes.`); } }