1

I am trying to make a flag guessing bot but in the part where it checks if the answer is right or not, it always returns false. I tried to debug with console logs and it turns out the m.content is an empty string, and in the m object it shows content: ''. Here is the code I used

const filter = m => m.author.id == interaction.user.id

        const collector = interaction.channel.createMessageCollector(
            {filter: filter, max: 2, time: 1000 * 30}
        )

        interaction.reply({ content: 'What flag is this? You have 30 seconds', files: [`./public/images/flags/${flag}.png`]})

        collector.on('collect', m => {
            console.log(m)
            console.log(m.content) //returns empty string
            if (m.content == flag) {
                flag = flags[Math.round(Math.random() * flags.length)].toLowerCase().replaceAll(' ', '')
                m.reply({ content: 'What flag is this? You have 30 seconds', files: [`./public/images/flags/${flag}.png`]})
            } else {
                return m.reply('You got it wrong. So sad.')
            }
        })

        collector.on('end', collected => {
            return console.log(collected)
        })

I tried to search on google but nothing shows up. I don't know why this is happening

ShedeurCoder
  • 11
  • 1
  • 4

0 Answers0