'Discord.js [not responding when message is sent after a button was clicked]

So I'm making a command that starts with a slash command, then you need to press a button, the bot send a emebed when you press the button, and then it waits for a message, and when the user sends a message the bot responds.

So here is how it goes:

  • slahs command
  • emebed with a button
  • chek if button is pressed and then send another embed
  • wait for users message check it and then sends something

Here is the code for the button message: `client.on('interactionCreate', async interaction => { if (!interaction.isCommand()) return;

if (interaction.commandName === 'reactor') {
    const row = new MessageActionRow()
        .addComponents(
            new MessageButton()
                .setCustomId('Start')
                .setLabel('Start')
                .setStyle('PRIMARY'),
        );

        const exampleEmbed = new MessageEmbed()
            .setTitle('Now you will the to grab the materials')
            .setDescription("Type out the words that will be given bt don't be too slow")

    await interaction.reply({ embeds: [exampleEmbed], components: [row] });
}

});`

Here is the code that cheks if the button is pressed sends a message and then waits for a spesific users message: `client.on("message", message => {

if (!message.isButton()) return; // cheking if is button

if (message.customId == "Start") { //if button clicked is start do this 
    const exampleEmbed = new MessageEmbed() //creating a message
        .setDescription('Type out the words that will be given')
        .setThumbnail('https://cdn.discordapp.com/attachments/844145839898492929/953741341186228354/Hk86.png')
    await interaction.reply({embeds: [exampleEmbed]}); //print out the embed

    message.channel.awaitMessages(m => m.author.id == message.author.id, //cheking the next message
        { max: 1, time: 30000 }).then(collected => { //sets timer and then collect info
            if (collected.first().content.toLowerCase() == 'Hk86') { //chek if message is yes
                message.reply('it works!');
            }
        });
} 

});`

And here are the imports:

const { Client, Collection, Intents, MessageActionRow, MessageButton, MessageEmbed} = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents: \[Intents.FLAGS.GUILDS\] });
client.commands = new Collection();


Solution 1:[1]

I think the reason the bot doesn't send a message is because you didn't include the GUILD_MESSAGES intent.

const client = new Discord.Client({
  intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_WEBHOOKS", "DIRECT_MESSAGES", "GUILD_BANS", "GUILD_MEMBERS", "GUILD_VOICE_STATES"], //must use intents
  allowedMentions: ["users"] //stops people from using +say @everyone
});

That's my code for my client.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Dharman