diff --git a/config.json b/config.json index 75a4115..4fd1a47 100644 --- a/config.json +++ b/config.json @@ -11,7 +11,8 @@ "confetti": ["568927056172285981"] }, "logChannel": "572870712428199951", - "logs": false + "logs": false, + "emuOnly": false }, "crowdsource": { "userToken": "NTQxNjYyNjgyODM1ODQ1MTIw.D0Y3TA.xnJuTkmYwI7ckwCkhGbkcMHsgR8", diff --git a/src/modules/hq-discord.js b/src/modules/hq-discord.js index 73452b0..5b6577b 100644 --- a/src/modules/hq-discord.js +++ b/src/modules/hq-discord.js @@ -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,25 +51,27 @@ export default async (client, prize) => { const weight = client.weights.hq[i]; embed.fields.push({ name: `${weight.toFixed(2)} | **${a.text}**`, value: '[]()' }); }); - channels.forEach(async (c) => { - const m = await c.send(embed); - const i = setInterval(() => { - const embed = new MessageEmbed() - .setTitle(`Question ${json.questionNumber}/${json.questionCount}:`) - .setColor('#373C98') - .setDescription(`**${json.question}**`); - json.answers.forEach((a, i) => { - const weight = client.weights.hq[i]; - embed.fields.push({ name: `${weight.toFixed(2)} | **${a.text}**`, value: '[]()' }); - }); - m.edit(embed); - }, 2000); - setTimeout(() => { - clearInterval(i); - const bestAnswer = client.weights.hq.indexOf(Math.max(...client.weights.hq)); - client.hqClients.forEach(c => c.submitAnswer(bestAnswer)); - }, 12000); - }); + if (!emuOnly) { + channels.forEach(async (c) => { + const m = await c.send(embed); + const i = setInterval(() => { + const embed = new MessageEmbed() + .setTitle(`Question ${json.questionNumber}/${json.questionCount}:`) + .setColor('#373C98') + .setDescription(`**${json.question}**`); + json.answers.forEach((a, i) => { + const weight = client.weights.hq[i]; + embed.fields.push({ name: `${weight.toFixed(2)} | **${a.text}**`, value: '[]()' }); + }); + m.edit(embed); + }, 2000); + setTimeout(() => { + clearInterval(i); + const bestAnswer = client.weights.hq.indexOf(Math.max(...client.weights.hq)); + client.hqClients.forEach(c => c.submitAnswer(bestAnswer)); + }, 12000); + }); + } } if (json.type === 'questionSummary') { const bestAnswer = client.weights.hq.indexOf(Math.max(...client.weights.hq)); @@ -87,11 +89,13 @@ export default async (client, prize) => { }); }); const correctIndex = json.answerCounts.map(a => a.correct).indexOf(true); - channels.forEach(async (c) => { - const m = await c.send(embed); - if (bestAnswer === correctIndex) await m.react('👍'); - else await m.react('👎'); - }); + 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);