[HQ, Config] Make checking balances much faster, config changes, and minor embed changes
This commit is contained in:
@@ -96,8 +96,9 @@
|
|||||||
"autoSplitOnLastQuestion": false,
|
"autoSplitOnLastQuestion": false,
|
||||||
"autoLife": true,
|
"autoLife": true,
|
||||||
"autoLifeQuestionThreshold": 9,
|
"autoLifeQuestionThreshold": 9,
|
||||||
"splitThreshold": 0.65,
|
"splitThreshold": 0.6,
|
||||||
"autoCheckpoints": true,
|
"autoCheckpoints": true,
|
||||||
"checkpointThreshold": 0.40
|
"checkpointThreshold": 0.40,
|
||||||
|
"maxLivesPerGame": 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -132,30 +132,38 @@ client.on('message', async (msg) => {
|
|||||||
const index = numberEmojis.indexOf(collected.array()[0].emoji.name);
|
const index = numberEmojis.indexOf(collected.array()[0].emoji.name);
|
||||||
const tokens = getTokens(tokenFiles[index]);
|
const tokens = getTokens(tokenFiles[index]);
|
||||||
const message = await msg.channel.send(`Checking ${tokens.length} tokens...`);
|
const message = await msg.channel.send(`Checking ${tokens.length} tokens...`);
|
||||||
let i = 1;
|
const startTime = Date.now();
|
||||||
let unlockedBalance = 0;
|
let unlockedBalance = 0;
|
||||||
let unlockedAccounts = 0;
|
let unlockedAccounts = 0;
|
||||||
let lockedBalance = 0;
|
let lockedBalance = 0;
|
||||||
let lockedAccounts = 0;
|
let lockedAccounts = 0;
|
||||||
let noBalance = 0;
|
let noBalance = 0;
|
||||||
|
let i = 1;
|
||||||
|
const tasks = [];
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
const hq = new HQClient(token, i);
|
// eslint-disable-next-line no-loop-func
|
||||||
await hq.login();
|
const promise = async () => {
|
||||||
const { balance, eligibleForPayout } = await hq.getBalance();
|
const hq = new HQClient(token, i);
|
||||||
if (eligibleForPayout) {
|
await hq.login();
|
||||||
unlockedAccounts += 1;
|
const { balance, eligibleForPayout } = await hq.getBalance();
|
||||||
unlockedBalance += balance;
|
if (eligibleForPayout) {
|
||||||
tokens[i - 1].locked = false;
|
unlockedAccounts += 1;
|
||||||
}
|
unlockedBalance += balance;
|
||||||
if (!eligibleForPayout && balance > 0) {
|
tokens[i - 1].locked = false;
|
||||||
lockedAccounts += 1;
|
}
|
||||||
lockedBalance += balance;
|
if (!eligibleForPayout && balance > 0) {
|
||||||
tokens[i - 1].locked = true;
|
lockedAccounts += 1;
|
||||||
}
|
lockedBalance += balance;
|
||||||
if (balance === 0) noBalance += 1;
|
tokens[i - 1].locked = true;
|
||||||
i += 1;
|
}
|
||||||
|
if (balance === 0) noBalance += 1;
|
||||||
|
i += 1;
|
||||||
|
return balance;
|
||||||
|
};
|
||||||
|
tasks.push(promise());
|
||||||
}
|
}
|
||||||
message.edit('Finished Checking Accounts!');
|
await Promise.all(tasks);
|
||||||
|
message.edit(`Finished Checking ${tokens.length} Accounts in ${(Date.now() - startTime) / 1000}s!`);
|
||||||
const embed = new MessageEmbed()
|
const embed = new MessageEmbed()
|
||||||
.setTitle('Balance')
|
.setTitle('Balance')
|
||||||
.addField('Unlocked Balance', `$${unlockedBalance.toFixed(2)} across ${unlockedAccounts} accounts`)
|
.addField('Unlocked Balance', `$${unlockedBalance.toFixed(2)} across ${unlockedAccounts} accounts`)
|
||||||
|
|||||||
@@ -15,26 +15,33 @@ export default async () => {
|
|||||||
let livesCount = 0;
|
let livesCount = 0;
|
||||||
let erasersCount = 0;
|
let erasersCount = 0;
|
||||||
let index = 0;
|
let index = 0;
|
||||||
|
const tasks = [];
|
||||||
|
const startTime = Date.now();
|
||||||
|
console.edit(`Checking ${tokens.length} accounts...`.yellow);
|
||||||
for (const token of tokens) {
|
for (const token of tokens) {
|
||||||
index += 1;
|
// eslint-disable-next-line no-loop-func
|
||||||
const client = new Client(token, index - 1);
|
const promise = async () => {
|
||||||
await client.login();
|
index += 1;
|
||||||
clients.push(client);
|
const client = new Client(token, index - 1);
|
||||||
const { balance, eligibleForPayout } = await client.getBalance();
|
await client.login();
|
||||||
const { lives, erase1s } = await client.getUserData();
|
clients.push(client);
|
||||||
livesCount += lives;
|
const { balance, eligibleForPayout } = await client.getBalance();
|
||||||
erasersCount += erase1s;
|
const { lives, erase1s } = await client.getUserData();
|
||||||
if (balance === 0) noBalanceCount += 1;
|
livesCount += lives;
|
||||||
if (eligibleForPayout) {
|
erasersCount += erase1s;
|
||||||
unlockedCount += 1;
|
if (balance === 0) noBalanceCount += 1;
|
||||||
unlockedBalance += balance;
|
if (eligibleForPayout) {
|
||||||
} else if (!eligibleForPayout && balance > 0) {
|
unlockedCount += 1;
|
||||||
lockedCount += 1;
|
unlockedBalance += balance;
|
||||||
lockedBalance += balance;
|
} else if (!eligibleForPayout && balance > 0) {
|
||||||
}
|
lockedCount += 1;
|
||||||
console.edit(`Checked ${index}/${tokens.length} accounts.`.yellow);
|
lockedBalance += balance;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
tasks.push(promise());
|
||||||
}
|
}
|
||||||
console.edit(`Finished checking ${tokens.length} accounts!`.green, true);
|
await Promise.all(tasks);
|
||||||
|
console.edit(`Finished checking ${tokens.length} accounts in ${(Date.now() - startTime) / 1000}s!`.green, true);
|
||||||
if (unlockedCount) console.log(`${' Unlocked Balance '.bgGreen.black} $${unlockedBalance.toFixed(2)} across ${unlockedCount} accounts`);
|
if (unlockedCount) console.log(`${' Unlocked Balance '.bgGreen.black} $${unlockedBalance.toFixed(2)} across ${unlockedCount} accounts`);
|
||||||
if (lockedCount) console.log(`${' Locked Balance '.bgRed.black} $${lockedBalance.toFixed(2)} across ${lockedCount} accounts`);
|
if (lockedCount) console.log(`${' Locked Balance '.bgRed.black} $${lockedBalance.toFixed(2)} across ${lockedCount} accounts`);
|
||||||
if (noBalanceCount) console.log(`${' No Balance '.bgYellow.black} ${noBalanceCount}`);
|
if (noBalanceCount) console.log(`${' No Balance '.bgYellow.black} ${noBalanceCount}`);
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ export default async (client, prize) => {
|
|||||||
});
|
});
|
||||||
master.ws.on('close', async () => {
|
master.ws.on('close', async () => {
|
||||||
if (!emuOnly) channels.forEach(c => c.send('**GAME OVER!**'));
|
if (!emuOnly) channels.forEach(c => c.send('**GAME OVER!**'));
|
||||||
const image = genResults('HQ Trivia', winners || 0, winnings || 0, `${correctCount}/${master.questionCount || 0}`);
|
const image = genResults('HQ Trivia', winners || 0, winnings || 0, `${correctCount}/${master.questionNumber || 0}`);
|
||||||
const attachment = new MessageAttachment(image);
|
const attachment = new MessageAttachment(image);
|
||||||
if (!emuOnly) channels.forEach(c => c.send(attachment));
|
if (!emuOnly) channels.forEach(c => c.send(attachment));
|
||||||
if (discord.logs) client.channels.get(discord.logChannel).send(attachment);
|
if (discord.logs) client.channels.get(discord.logChannel).send(attachment);
|
||||||
|
|||||||
Reference in New Issue
Block a user