Fix answer sending and add push_discord config var.

This commit is contained in:
eTronic
2018-10-25 18:12:33 -04:00
parent 4fdde0cba6
commit 08fd1a02cb
2 changed files with 6 additions and 4 deletions

View File

@@ -8,5 +8,7 @@
"register": "/parse/users"
},
"discord_token": "NTA0MDQwNTI0NDI5MjYyODQ4.Dq_mEg.GC0SXdL0aj0hNvktuucA41QKzQo",
"discord_channel": "504041066559963137"
"discord_channel": "504041066559963137",
"accept_userid": "111146692547473408",
"PUSH_DISCORD": false
}

View File

@@ -114,7 +114,7 @@ class Player {
if (data && data[0] && data[0].game) {
this.game = data[0].game;
if (this.game.currentState === 'GAME_LOBBY' && this.isMaster) {
if (this.game.currentState === 'GAME_LOBBY' && this.isMaster && config.PUSH_DISCORD) {
this.showQuestions();
}
}
@@ -251,7 +251,7 @@ class Game {
sendAnswers(questionIndex) {
const answer = this.answers[questionIndex] || 'split';
if (['1', '2', '3'].includes(answer)) {
if ([1, 2, 3].includes(answer)) {
log.info(`Sending answer ${answer} for Question ${questionIndex + 1}.`);
this.players.forEach(player => player.sendAnswer(parseInt(answer)));
} else {
@@ -317,7 +317,7 @@ client.on('message', (msg) => {
if (!guild || !channel) return;
const { author, content } = msg;
const { id, username } = author;
const { id } = author;
if (id !== config.accept_userid) return;
if (content.startsWith('!answers')) {