feat(*): Finish implementing start command

This commit is contained in:
2020-11-19 23:24:59 +00:00
parent f6af7b4327
commit 49cd612f51
+24 -10
View File
@@ -286,15 +286,22 @@ client.on('message', function (message) {
logger.info(`${message.author.username} used command lq in ${message.channel.name}`); logger.info(`${message.author.username} used command lq in ${message.channel.name}`);
logger.log('info', `${message.author.username} left the queue.`);
message.channel.send(`${message.author.username} left the queue.`);
for( var i = 0; i < playerQueue.length; i++){ for( var i = 0; i < playerQueue.length; i++){
if ( playerQueue[i] === message.author) { if ( playerQueue[i] === message.author) {
playerQueue.splice(i, 1); playerQueue.splice(i, 1);
i--; i--;
} }
} }
for( var i = 0; i < playerVotes.length; i++){
if ( playerVotes[i] === message.author) {
playerVotes.splice(i, 1);
i--;
}
}
logger.log('info', `${message.author.username} left the queue.`);
message.channel.send(`${message.author.username} left the queue.`);
checkQueue(message); checkQueue(message);
} }
@@ -325,18 +332,18 @@ client.on('message', function (message) {
// First player to vote // First player to vote
playerVotes.push(message.author); playerVotes.push(message.author);
message.channel.send(`=====\n${message.author.username} voted to start the adventure.\nAll other players in the queue must also vote to start the adventure for it to begin without ${maxqueuesize} players.`); message.channel.send(`=====\n${message.author.username} voted to start the adventure.\nAll other players in the queue must also vote to start the adventure for it to begin without ${config.maxqueuesize} players.`);
} }
else if (playerVotes.includes(message.author.username)) { else if (playerVotes.includes(message.author.username)) {
message.channel.send(`=====\n${message.author.username} has already voted to start the adventure.\nAll other players in the queue must also vote to start the adventure for it to begin without ${maxqueuesize} players.`); message.channel.send(`=====\n${message.author.username} has already voted to start the adventure.\nAll other players in the queue must also vote to start the adventure for it to begin without ${config.maxqueuesize} players.`);
} }
else if (playerVotes.length < maxqueuesize) { else if (playerVotes.length < config.maxqueuesize) {
// Not the first player to vote // Not the first player to vote
playerVotes.push(message.author); playerVotes.push(message.author);
if (playerVotes.length < maxqueuesize) { if (playerVotes.length < playerQueue.length) {
// Still not all players voted // Still not all players voted
message.channel.send(`=====\n${message.author.username} voted to start the adventure.\nAll other players in the queue must also vote to start the adventure for it to begin without ${maxqueuesize} players.`); message.channel.send(`=====\n${message.author.username} voted to start the adventure.\nAll other players in the queue must also vote to start the adventure for it to begin without ${config.maxqueuesize} players.`);
} }
else { else {
// All players have voted, we can start the adventure early // All players have voted, we can start the adventure early
@@ -398,6 +405,13 @@ client.on('message', function (message) {
} }
} }
for( var i = 0; i < playerVotes.length; i++){
if ( playerVotes[i].username === user.username) {
playerVotes.splice(i, 1);
i--;
}
}
message.channel.send(`${user.username} removed from queue.`); message.channel.send(`${user.username} removed from queue.`);
logger.log('info', `${message.author.username} removed ${user.username} from queue.`); logger.log('info', `${message.author.username} removed ${user.username} from queue.`);