Discord.js [单击按钮后发送消息时无响应]

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

所以我正在制作一个以斜杠命令开头的命令,然后你需要按下一个按钮,当你按下按钮时机器人会发送一个 emebed,然后它等待消息,当用户发送机器人响应的消息。

事情是这样的:

这是按钮消息的代码: `client.on('interactionCreate', 异步交互 => { 如果 (!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] });
}

});`

下面是检查按钮是否被按下发送消息然后等待特定用户消息的代码: `client.on("消息", 消息 => {

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!');
            }
        });
} 

});`

这里是导入:

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();

我认为机器人不发送消息的原因是您没有包含 GUILD_MESSAGES 意图。

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
});

这是我给客户的代码。