feat(*): Add pokemon name and captain name argument support

This commit is contained in:
2020-10-26 08:10:03 +00:00
parent fdfafc919b
commit 88794261b1
+18 -2
View File
@@ -27,9 +27,11 @@ if (process.env.NODE_ENV !== 'production') {
})); }));
} }
const queueTitle = '===== QUEUE ====='; const queueTitle = '===== ADVENTURE QUEUE =====';
let playerQueue = []; let playerQueue = [];
let pokemonName = '';
let captainInGameName = '';
client.login(config.token); client.login(config.token);
client.once('ready', () =>{ client.once('ready', () =>{
@@ -64,7 +66,7 @@ function checkQueue(message) {
// DM users // DM users
const randomCode = generateRandomCode(); const randomCode = generateRandomCode();
playerQueue.forEach(player => { playerQueue.forEach(player => {
client.users.cache.get(player.id).send(`Here is your link code ${randomCode} - @${playerQueue[0].username} is making the lobby, have fun!`); client.users.cache.get(player.id).send(`${queueTitle}\nPokemon: ${pokemonName}\Captain's IGN: ${captainInGameName}\nHere is your link code ${randomCode} - @${playerQueue[0].username} is making the lobby, have fun!`);
}); });
} catch (error) { } catch (error) {
logger.log('error', error); logger.log('error', error);
@@ -77,12 +79,20 @@ function checkQueue(message) {
} }
else if (playerQueue.length === 0) { else if (playerQueue.length === 0) {
message.channel.send('The queue is empty :('); message.channel.send('The queue is empty :(');
pokemonName = '';
captainInGameName = '';
} }
else { else {
// Show queue after adding // Show queue after adding
if (pokemonName.length > 0 && captainInGameName.length > 0) {
message.channel.send(`${queueTitle}\nPokemon: ${pokemonName}\Captain's IGN: ${captainInGameName}\n${playerQueue.map((player, index) => `${index + 1} - ${player.username}`).join('\n')}`);
}
else {
message.channel.send(`${queueTitle}\n${playerQueue.map((player, index) => `${index + 1} - ${player.username}`).join('\n')}`); message.channel.send(`${queueTitle}\n${playerQueue.map((player, index) => `${index + 1} - ${player.username}`).join('\n')}`);
} }
} }
}
function getUserFromMention(mention) { function getUserFromMention(mention) {
if (!mention) return; if (!mention) return;
@@ -117,6 +127,12 @@ client.on('message', function (message) {
playerQueue.push(message.author); playerQueue.push(message.author);
if (playerQueue.length === 1 && args[0] && args[1]) {
// First player can submit pokemon and in-game name
pokemonName = args[0];
captainInGameName = args[1];
}
checkQueue(message); checkQueue(message);
} }
else if (command === 'q' && (playerQueue.includes(message.author))) { else if (command === 'q' && (playerQueue.includes(message.author))) {