Bot 不等待反应或消息

Bot doesn't wait for reaction or for message

正如你所看到的,这是一个有 2 个选项的建议命令,但是当我输入 .sug 时,机器人发送了嵌入,这很好,但是他立即发送了 A 表情符号的消息,然后他立即发送 "Your suggestion has been filled to the stuff team" 甚至没有我做任何事情。也没有错误。我认为机器人为什么会将自己对自己的消息的反应视为用户的反应,然后他认为由于他自己的反应(可能)而发送的 "Please suggest something for...." 是来自用户的建议消息,所以他发送 "Your suggestion has been filled to the stuff team" 这是一个 link 的截图:https://ibb.co/KwMBmtc

execute(message, client, args) {
        const Discord = require('discord.js');

        let Embed = new Discord.MessageEmbed()
            .setColor('0x0099ff')
            .setDescription(`Suggestion categories`)
            .addField(`For what you want to suggest something?`, `\nA: I want to suggest something for the Website/Servers/Discord Server\nB: I want to suggest something for the CloudX Bot \n\nPlease react to this message with A or B`)

        message.channel.send(Embed)
        .then(function (message) {
            message.react("")
            message.react("")
            const filter = (reaction, user) => {
                return ['', ''].includes(reaction.emoji.name) && user.id;
        };

        message.awaitReactions(filter, { max: 1 })
                .then(collected => {
                    const reaction = collected.first();

                    if (reaction.emoji.name === '') {
                        const filter = m => m.author.id === message.author.id;

                        message.channel.send(`Please provide a suggestion for the Website/Servers/Discord Server or cancel this command with "cancel"!`)

                        message.channel.awaitMessages(filter, { max: 1, })
                            .then(async (collected) => {
                                if (collected.first().content.toLowerCase() === 'cancel') {
                                    message.reply("Your suggestion has been cancelled.")
                                }
                                else {
                                    let embed1 = new Discord.MessageEmbed()
                                        .setColor('0x0099ff')
                                        .setAuthor(`${message.author.tag}`)
                                        .addField(`New Suggestion:`, `${collected.first().content}`)
                                        .setFooter(client.user.username, "attachment://CloudX.png")
                                        .setTimestamp();

                                    const channel = await client.channels.fetch("705781201469964308")
                                    channel.send({embed: embed1, files: [{
                                        attachment:'CloudX.png',
                                        name:'CloudX.png'
                                        }]})

                                    message.channel.send(`Your suggestion has been filled to the staff team. Thank you!`)
                                } 
                        })
                    }
                    if (reaction.emoji.name === '') {
                        const filter = m => m.author.id === message.author.id;

                        message.channel.send(`Please provide a suggestion for the CloudX Bot or cancel this command with "cancel"!`)

                        message.channel.awaitMessages(filter, { max: 1, })
                            .then(async (collected) => {
                                if (collected.first().content.toLowerCase() === 'cancel') {
                                    message.reply("Your suggestion has been cancelled.")
                                }
                                else {
                                    let embed2 = new Discord.MessageEmbed()
                                        .setColor('0x0099ff')
                                        .setAuthor(`${message.author.tag}`)
                                        .addField(`New Suggestion:`, `${collected.first().content}`)
                                        .setFooter(client.user.username, "attachment://CloudX.png")
                                        .setTimestamp();

                                    const channel = await client.channels.fetch("702825446248808519")
                                    channel.send({embed: embed2, files: [{
                                        attachment:'CloudX.png',
                                        name:'CloudX.png'
                                        }]})

                                    message.channel.send(`Your suggestion has been filled to the staff team. Thank you!`)
                                } 
                        })
                    }    
                })
        })
    },

I think the bot somewhy takes his own reaction to his own message as a reaction from the user

你完全正确。机器人正在收集自己的消息和反应,因为您在发送它们后没有使用 .then,所以 awaitMessagesawaitReactions 大致在您发送消息的同时被调用。

要解决此问题,您需要为机器人执行的每个操作(发送消息、回复)使用 .then

message.channel.send(Embed).then((message) => {
    message.react("").then(() => {
        message.react("").then(() => {
            message.awaitReactions(filter, { max: 1 }).then(collected => {
                // Do stuff with the collected reaction
            })
        })
    })
})

这样,它只在最后一段代码完成后运行下一段代码,避免收集自己的动作。