Discord.js 在DM通道中等待消息

Discord.js 在DM通道中等待消息,discord.js,Discord.js,我正在尝试使用Discord.js在Discord上发布一个公告机器人,当有人键入-na it DM时,会给他们一个嵌入,然后接受他们的输入,生成一个变量作为他们的输入,然后进行几次该过程。我遇到的问题是,当我运行bot,然后执行命令-na时,它会给我一个错误,即:TypeError:cannotreadproperty'awaitMessages'的undefined。 这是我的密码: const allyAnnouncementChannel = client.channels.cache.

我正在尝试使用Discord.js在Discord上发布一个公告机器人,当有人键入-na it DM时,会给他们一个嵌入,然后接受他们的输入,生成一个变量作为他们的输入,然后进行几次该过程。我遇到的问题是,当我运行bot,然后执行命令-na时,它会给我一个错误,即:TypeError:cannotreadproperty'awaitMessages'的undefined。 这是我的密码:

const allyAnnouncementChannel = client.channels.cache.get('756701256122236941')

msg.member
返回一个对象。但是,该属性仅在上可用

msg.author.dmChannel.awaitMessages(…)//将'msg.member'更改为'msg.author'`

TypeError:无法读取null属性'waitMessages',这是我执行命令时遇到的错误。您必须将
msg.member
替换为
msg.author
我将其更改为null,但它仍然给我该错误。
if (msg.content === '-na') {
        if (msg.channel === Discord.DMChannel) {
            return
            } else
            if (msg.member.roles.cache.has('756713479003701338')) {
                msg.author.send(Ping);

                msg.member.dmChannel.awaitMessages(m => m.author.id === msg.author.id,
                    {max: 1, time: 300000}).then(collected => {
                            msg.author.send(Title);
                            EmbedPing = collected.first().content;

                            msg.member.dmChannel.awaitMessages(m => m.author.id === msg.author.id,
                                {max: 1, time: 300000}).then(collected => {
                                    msg.author.send(Message);
                                    EmbedTitle = collected.first().content;

                                    msg.member.dmChannel.awaitMessages(m => m.author.id === msg.author.id,
                                        {max: 1, time: 300000}).then(collected => {
                                            msg.author.send(Image);
                                            EmbedMessage = collected.first().content;
                                            
                                            msg.member.dmChannel.awaitMessages(m => m.author.id === msg.author.id,
                                                {max: 1, time: 300000}).then(collected => {
                                                    if (collected.first().content.toLowerCase() === 'yes') {
                                                        msg.author.send(ImageURL);
                                                        EmbedImage = collected.first().content;

                                                        var FinishedEmbedImage = new Discord.MessageEmbed()
                                                            .setColor('#FFD700')
                                                            .setTitle(EmbedTitle)
                                                            .setDescription(EmbedMessage)
                                                            .setImage(EmbedImage)
                                                            .setTimestamp()
                                                            .setFooter('Sent By: ' + msg.author)

                                                        allyAnnouncementChannel.send(EmbedPing, FinishedEmbed);

                                                    } else
                                                    msg.author.send(Finished);

                                                    var FinishedEmbed = new Discord.MessageEmbed()
                                                        .setColor('#FFD700')
                                                        .setTitle(EmbedTitle)
                                                        .setDescription(EmbedMessage)
                                                        .setTimestamp()
                                                        .setFooter('Sent By: ' + msg.author)

                                                    allyAnnouncementChannel.send(EmbedPing, FinishedEmbed);
                                                }).catch(new Discord.MessageEmbed
                                                    .setColor('#FFD700')
                                                    .setTitle('Announcement Cancelled')
                                                    .setDescription('It has been 5 minutes without a response. The announcement has been cancelled.')
                                                    .setFooter('Please do the command again if you wish to send an announcement.'))
                                        }).catch(new Discord.MessageEmbed
                                            .setColor('#FFD700')
                                            .setTitle('Announcement Cancelled')
                                            .setDescription('It has been 5 minutes without a response. The announcement has been cancelled.')
                                            .setFooter('Please do the command again if you wish to send an announcement.'))
                                }).catch(new Discord.MessageEmbed
                                    .setColor('#FFD700')
                                    .setTitle('Announcement Cancelled')
                                    .setDescription('It has been 5 minutes without a response. The announcement has been cancelled.')
                                    .setFooter('Please do the command again if you wish to send an announcement.'))
                    }).catch(new Discord.MessageEmbed
                                .setColor('#FFD700')
                                .setTitle('Announcement Cancelled')
                                .setDescription('It has been 5 minutes without a response. The announcement has been cancelled.')
                                .setFooter('Please do the command again if you wish to send an announcement.'))
        };
    };
});