Browse Source

Fix broken filters and only allow responses to the most recent message from the bot

pull/33/head
Abheek Dhawan 3 years ago
parent
commit
0ec3abe8dd
Signed by: abheekd GPG Key ID: 7BE81B8C14475B67
  1. 8
      commands/train.js

8
commands/train.js

@ -97,16 +97,18 @@ module.exports = {
const data = res.data.question; const data = res.data.question;
const tossupQuestion = data.tossup_question; const tossupQuestion = data.tossup_question;
const tossupAnswer = data.tossup_answer; const tossupAnswer = data.tossup_answer;
const messageFilter = message => message.author.id === interaction.author.id;
interaction.followUp({ content: decode(tossupQuestion) + `\n\n||Source: ${data.uri}||` }) interaction.followUp({ content: decode(tossupQuestion) + `\n\n||Source: ${data.uri}||` })
.then(() => { .then(() => {
const messageFilter = m => m.author.id === interaction.user.id || m.author.id === interaction.client.user.id;
interaction.channel.awaitMessages({ interaction.channel.awaitMessages({
messageFilter, filter: messageFilter,
max: 1, max: 1,
}) })
.then(collected => { .then(collected => {
const answerMsg = collected.first(); const answerMsg = collected.first();
if (answerMsg.author.id === interaction.client.user.id) return;
let predicted = null; let predicted = null;
if (data.tossup_format === 'Multiple Choice') { if (data.tossup_format === 'Multiple Choice') {
if ( if (
@ -154,7 +156,7 @@ module.exports = {
}; };
overrideMsg overrideMsg
.awaitReactions({ .awaitReactions({
filter, filter: filter,
max: 1, max: 1,
}) })
.then(() => { .then(() => {

Loading…
Cancel
Save