feat(*): Add a queue player counter to the queue title

This commit is contained in:
2020-10-26 16:46:28 +00:00
parent a80a4b8dfc
commit 7c742d8b48
+8 -7
View File
@@ -26,9 +26,6 @@ if (process.env.NODE_ENV !== 'production') {
format: winston.format.simple(), format: winston.format.simple(),
})); }));
} }
const queueTitle = '\n===== ADVENTURE QUEUE =====';
let playerQueue = []; let playerQueue = [];
let pokemonName = ''; let pokemonName = '';
let captainInGameName = ''; let captainInGameName = '';
@@ -49,6 +46,10 @@ client.once('ready', () =>{
* dc - Delete an adventure channel (only the captain can use this) * dc - Delete an adventure channel (only the captain can use this)
*/ */
function generateQueueTitle() {
return `\n===== ADVENTURE QUEUE (${playerQueue.length}/${config.maxqueuesize}) =====`;
}
function generateRandomCode() { function generateRandomCode() {
const num1 = Math.floor((Math.random() * 9999) + 1); const num1 = Math.floor((Math.random() * 9999) + 1);
const num2 = Math.floor((Math.random() * 9999) + 1); const num2 = Math.floor((Math.random() * 9999) + 1);
@@ -70,10 +71,10 @@ function checkQueue(message) {
const randomCode = generateRandomCode(); const randomCode = generateRandomCode();
playerQueue.forEach(player => { playerQueue.forEach(player => {
if (pokemonName === '' && captainInGameName === '') { if (pokemonName === '' && captainInGameName === '') {
client.users.cache.get(player.id).send(`${queueTitle}\nHere is your link code ${randomCode} - @${playerQueue[0].username} is making the lobby, have fun!`); client.users.cache.get(player.id).send(`${generateQueueTitle()}\nHere is your link code ${randomCode} - @${playerQueue[0].username} is making the lobby, have fun!`);
} }
else { else {
client.users.cache.get(player.id).send(`${queueTitle}\nPokemon: ${pokemonName}\nCaptain's IGN: ${captainInGameName}\nHere is your link code ${randomCode} - @${playerQueue[0].username} is making the lobby, have fun!`); client.users.cache.get(player.id).send(`${generateQueueTitle()}\nPokemon: ${pokemonName}\nCaptain's IGN: ${captainInGameName}\nHere is your link code ${randomCode} - @${playerQueue[0].username} is making the lobby, have fun!`);
} }
}); });
} catch (error) { } catch (error) {
@@ -95,10 +96,10 @@ function checkQueue(message) {
else { else {
// Show queue after adding // Show queue after adding
if (pokemonName === '' && captainInGameName === '') { if (pokemonName === '' && captainInGameName === '') {
message.channel.send(`${queueTitle}\n${playerQueue.map((player, index) => `${index + 1} - ${player.username}`).join('\n')}`); message.channel.send(`${generateQueueTitle()}\n${playerQueue.map((player, index) => `${index + 1} - ${player.username}`).join('\n')}`);
} }
else { else {
message.channel.send(`${queueTitle}\nPokemon: ${pokemonName}\nCaptain's IGN: ${captainInGameName}\n${playerQueue.map((player, index) => `${index + 1} - ${player.username}`).join('\n')}`); message.channel.send(`${generateQueueTitle()}\nPokemon: ${pokemonName}\nCaptain's IGN: ${captainInGameName}\n${playerQueue.map((player, index) => `${index + 1} - ${player.username}`).join('\n')}`);
} }
} }
} }