Sme 答案变体不起作用 discord.js

Sme answer variants not working discord.js

我试着制作一个角色问答机器人,当我写 .tc 时它会显示一个随机字符,你必须在 15 秒内回答这个角色的名字,它的代码在一个名为 triviachar.js 并且所有答案变体都作为变量放在名为 triviacharacterlist.js 的 js 文件中,但我遇到了一个问题,其中一些答案变体可以工作,但其他答案变体不起作用。这是我什至遇到过的最奇怪的机器人行为,所以如果你能帮助我,那将意义重大,这是代码。 (我也不太擅长编程)(顺便说一句,我正在使用 discord.js-commando):

(这些文件中还有更多代码,但有点像这个)

triviachar.js:

run(msg) {
    const fivePoint = "Be3 bo6 u have asnwer correct, but u have answer without anime/game name so u get 5 points only lel";
    const tenPoint = "Bo3 bo6 u have answer correct with anime/game name so u get 10 points instead pog"
    const guessCharacterString = "Guess character bo3"
    var characterRandom = Math.floor(Math.random() * 5);

    if (characterRandom == 0) {
        const iKF = Characters.KiritoVariants;
        const triviaKiritoEmbed = new MessageEmbed()
            .setColor('#008fff')
            .setTitle(guessCharacterString)
            .setImage(Characters.CharacterImgs.kiritoimg)
    
        msg.channel.send(triviaKiritoEmbed)

        const filterK = m => m.content.includes(iKF.kirito0 || iKF.kirito1 || iKF.kirito2 || iKF.kirito3 || iKF.kirito4 || iKF.kirito5 || iKF.kirito6 || iKF.kirito7 || iKF.kirito8);
        msg.channel.awaitMessages(filterK, { max: 1, time: 15000, errors: ['time'] })
        .then(collected => {switch(collected.first().content){
            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'));
    }

triviacharacterlist.js:

//character images -------------------------------------------------------------------------------------------------------------
const CharacterImgs = {
    kiritoimg: "https://i.pinimg.com/originals/05/b8/d9/05b8d9a934b8d831fef385e7f60b5625.jpg",
    asunaimg: "https://pm1.narvii.com/6210/87c8712f955134bdbfe4135fbded8366ea21f917_00.jpg",
    jojoimg: "https://images-wixmp-ed30a86b8c4ca887773594c2.wixmp.com/f/f6ec6f25-09b6-414d-aeac-9a7cb7527ee7/dcdtfn4-618039ef-f3ee-4333-90a0-208fb4d0db2d.png?token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJ1cm46YXBwOiIsImlzcyI6InVybjphcHA6Iiwib2JqIjpbW3sicGF0aCI6IlwvZlwvZjZlYzZmMjUtMDliNi00MTRkLWFlYWMtOWE3Y2I3NTI3ZWU3XC9kY2R0Zm40LTYxODAzOWVmLWYzZWUtNDMzMy05MGEwLTIwOGZiNGQwZGIyZC5wbmcifV1dLCJhdWQiOlsidXJuOnNlcnZpY2U6ZmlsZS5kb3dubG9hZCJdfQ.QpJ2Po7ZB8AlZsmtuMH1O6zg7GpGWMo_RW-126L8ftI",
    dekuimg: "https://media.discordapp.net/attachments/472313197836107780/606995677737779211/XokvvZc.png",
    senkuimg: "https://pm1.narvii.com/7346/a2bb65cfca86e3d2bf85f1b12e2132af3d43f5f6r1-736-1041v2_uhq.jpg"
};

//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'
};

这些是不和谐的图像: https://i.stack.imgur.com/RkAf6.png https://i.stack.imgur.com/gfBAh.png

您的消息收集器过滤器设置有误。使用 || 链接变量不会执行您打算使用它的操作。有关详细信息,请查看 Logical OR operator.

简而言之,您的消息收集器过滤器仅收集内容包含 iKF.kirito0 值的消息。

解决此问题的方法是将所有值存储在一个数组中,并检查消息是否至少包含该数组的一个值。请参阅下面的代码示例。

const possibleAnswers = [iKF.kirito0, iKF.kirito1, iKF.kirito2, etc...];

const filterK = m => possibleAnswers.some(answer => m.content.includes(answer));