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