[HQ] Add emu-only mode (no embeds)
This commit is contained in:
@@ -11,7 +11,8 @@
|
||||
"confetti": ["568927056172285981"]
|
||||
},
|
||||
"logChannel": "572870712428199951",
|
||||
"logs": false
|
||||
"logs": false,
|
||||
"emuOnly": false
|
||||
},
|
||||
"crowdsource": {
|
||||
"userToken": "NTQxNjYyNjgyODM1ODQ1MTIw.D0Y3TA.xnJuTkmYwI7ckwCkhGbkcMHsgR8",
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable no-useless-escape */
|
||||
import { MessageEmbed, MessageAttachment } from 'discord.js';
|
||||
import Client from '../classes/Client';
|
||||
import { discord } from '../../config';
|
||||
import { discord, emuOnly } from '../../config';
|
||||
import { getTokens } from '../utils/tokens';
|
||||
import search from '../utils/google';
|
||||
import genResults from '../utils/img';
|
||||
@@ -21,7 +21,7 @@ export default async (client, prize) => {
|
||||
.setTitle('Game Live!')
|
||||
.setDescription(`HQ Trivia is live for **$${(prize || 5000).toLocaleString('en')}!**`)
|
||||
.setColor('#373C98');
|
||||
channels.forEach(c => c.send(embed));
|
||||
if (!emuOnly) channels.forEach(c => c.send(embed));
|
||||
let correctCount = 0;
|
||||
let questionCount;
|
||||
let questionNumber;
|
||||
@@ -51,6 +51,7 @@ export default async (client, prize) => {
|
||||
const weight = client.weights.hq[i];
|
||||
embed.fields.push({ name: `${weight.toFixed(2)} | **${a.text}**`, value: '[]()' });
|
||||
});
|
||||
if (!emuOnly) {
|
||||
channels.forEach(async (c) => {
|
||||
const m = await c.send(embed);
|
||||
const i = setInterval(() => {
|
||||
@@ -71,6 +72,7 @@ export default async (client, prize) => {
|
||||
}, 12000);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (json.type === 'questionSummary') {
|
||||
const bestAnswer = client.weights.hq.indexOf(Math.max(...client.weights.hq));
|
||||
winners = json.advancingPlayersCount;
|
||||
@@ -87,11 +89,13 @@ export default async (client, prize) => {
|
||||
});
|
||||
});
|
||||
const correctIndex = json.answerCounts.map(a => a.correct).indexOf(true);
|
||||
if (!emuOnly) {
|
||||
channels.forEach(async (c) => {
|
||||
const m = await c.send(embed);
|
||||
if (bestAnswer === correctIndex) await m.react('👍');
|
||||
else await m.react('👎');
|
||||
});
|
||||
}
|
||||
if (correctIndex === bestAnswer) correctCount += 1;
|
||||
const correctUsers = client.userAnswers.hq.filter(u => u.answer === (correctIndex + 1));
|
||||
const incorrectUsers = client.userAnswers.hq.filter(u => u.answer !== (correctIndex + 1));
|
||||
@@ -113,10 +117,10 @@ export default async (client, prize) => {
|
||||
}
|
||||
});
|
||||
master.ws.on('close', async () => {
|
||||
channels.forEach(c => c.send('**GAME OVER!**'));
|
||||
if (!emuOnly) channels.forEach(c => c.send('**GAME OVER!**'));
|
||||
const image = genResults('HQ Trivia', winners, winnings, `${correctCount}/${questionCount}`);
|
||||
const attachment = new MessageAttachment(image);
|
||||
channels.forEach(c => c.send(attachment));
|
||||
if (!emuOnly) channels.forEach(c => c.send(attachment));
|
||||
});
|
||||
tokens.forEach(async (t, i) => {
|
||||
const hq = new Client(t, i + 1);
|
||||
|
||||
Reference in New Issue
Block a user