I am trying to use the discord.js awaitMessages
method but it doesn't seem to work with uppercase letters because my possible answers (triviacharacterslist.js
) are all lowercase. I tried to convert this (in the code) but it doesn't seem to work.
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'
};
question from:
https://stackoverflow.com/questions/65933897/dont-know-how-to-change-to-lowercase-in-this-scenario 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…