我正在尝试使用 discord.jsawaitMessages
方法,但它似乎不适用于大写字母,因为我可能的答案 ( triviacharacterslist.js
) 都是小写字母。我试图转换它(在代码中),但它似乎不起作用。
triviachar.js
:
const iKF = Characters.KiritoVariants;
const possibleAnswers = [iKF.kirito0, iKF.kirito1, iKF.kirito2, iKF.kirito3, iKF.kirito4, iKF.kirito5, iKF.kirito6, iKF.kirito7, iKF.kirito8];
const triviaKiritoEmbed = new MessageEmbed()
.setColor('#008fff')
.setTitle(guessCharacterString)
.setImage(Characters.CharacterImgs.kiritoimg)
msg.channel.send(triviaKiritoEmbed)
const filterK = m => possibleAnswers.some(answer => m.content.includes(answer));
msg.channel.awaitMessages(filterK, { max: 1, time: 15000, errors: ['time'] })
.then(collected => {switch(collected.first().content.toLowerCase()){
case Characters.KiritoVariants.kirito0:
msg.channel.send(fivePoint);
break;
case Characters.KiritoVariants.kirito3:
msg.channel.send(fivePoint);
break;
case Characters.KiritoVariants.kirito6:
msg.channel.send(fivePoint);
break;
case Characters.KiritoVariants.kirito1:
msg.channel.send(tenPoint);
break;
case Characters.KiritoVariants.kirito2:
msg.channel.send(tenPoint);
break;
case Characters.KiritoVariants.kirito4:
msg.channel.send(tenPoint);
break;
case Characters.KiritoVariants.kirito5:
msg.channel.send(tenPoint);
break;
case Characters.KiritoVariants.kirito7:
msg.channel.send(tenPoint);
break;
case Characters.KiritoVariants.kirito8:
msg.channel.send(tenPoint);
break;
}})
.catch(collected => msg.channel.send('too bad u took too long ya 3am'));
}
triviacharacterslist.js
:
//character names ---------------------------------------------------------------------------------------------------------------
const KiritoVariants = {
kirito0: 'kirito',
kirito1: 'kirito sao',
kirito2: 'kirito sword art online',
kirito3: 'kazuto',
kirito4: 'kazuto sao',
kirito5: 'kazuto sword art online',
kirito6: 'kazuto kirigaya',
kirito7: 'kazuto kirigaya sao',
kirito8: 'kazuto kirigaya sword art online'
};