Discord.js 关于forEach循环的讨论

Discord.js 关于forEach循环的讨论,discord.js,Discord.js,我真的很困惑,为什么这段代码不工作,我打算它如何工作。这是我的密码: bot.on("message", async msg => { if (msg.content.startsWith(`${prefix}apply`)) { let ban = BannedArray.forEach(banned => { if(msg.author.id === banned) { msg.d

我真的很困惑,为什么这段代码不工作,我打算它如何工作。这是我的密码:

bot.on("message", async msg => {
    if (msg.content.startsWith(`${prefix}apply`)) {
        let ban = BannedArray.forEach(banned => {
            if(msg.author.id === banned) {
                msg.delete()
                msg.channel.send("You are banned.")
            }
        })
        if (msg.channel.id === "771665046514040833") {
                    var user = msg.content.split(" ").slice(1).join(" ")
                    const loading = new Discord.MessageEmbed()
                        .setTitle("Fetching your user ID...")
                    msg2 = await msg.channel.send(loading)
                    rapi.getUserIdFromUsername(user).then(async found => {
                        if (found === false) {
                            msg2.edit("test")
                        } else {
                            const found2 = new Discord.MessageEmbed()
                                .setTitle("User ID Found")
                                .setThumbnail(found.getAvatarBustImage)
                                .setDescription("We have found a User ID Linked to your account. It is: " + found.id + ". Is this you? \n [Click here to go to the profile](https://www.roblox.com/users/" + found.id + "/profile) \n \n ***PLEASE NOTE THAT IF YOU REACT WITH ✅ THAT YOUR ID WILL BE STORED FOR READING PURPOSES.***")
                            msg2.edit(found2)
                            msg.delete()
                            msg2.react('✅').then(r => {
                                msg2.react('❎');
                            });
                            msg2.awaitReactions((reaction, user) => user.id == msg.author.id && (reaction.emoji.name == '❎' || reaction.emoji.name == '✅'),
                                { max: 1, time: 30000 }).then(async collected => {
                                    if (collected.first().emoji.name == '❎') {
                                        msg.reply("The ID has not been stored.")
                                    }
                                    if (collected.first().emoji.name == '✅') {
                                        IDarray.push(`${found.id} || ${found.name}`)
                                        console.log(found.id + " || " + found.name)
                                        bot.channels.cache.get("771406620570943548").send("New ID pushed to table. Use `idarray` to see the full list. \n Roblox ID of user: " + found.id + " \n Roblox Name: " + found.name)
                                        const check = new Discord.MessageEmbed()
                                            .setTitle("Success")
                                            .setDescription("Your ID has now been saved. Please open your DMs for this application so I can DM you. \n Question 1: \n Have you had experience with this job before?")
                                        msg3 = await msg2.edit(check)
                                        msg2.reactions.removeAll()
                                        const filter = (m) => m.author.id === msg.author.id
                                        msg3.channel.awaitMessages(filter, { max: 1, time: false })
                                            .then(async collected => {
                                                const msg = collected.first()
                                                var Reply1 = msg.content.split(' ').slice(0).join(' ');
                                                if (msg.content === `${Reply1}`) {
                                                    msg.delete()
                                                    const ques2 = new Discord.MessageEmbed()
                                                        .setTitle("Question 2")
                                                        .setDescription("Why should we choose you over other applicants?")
                                                    msg4 = await msg3.edit(ques2)
                                                    const filter2 = (m) => m.author.id === msg.author.id
                                                    msg4.channel.awaitMessages(filter2, { max: 1, time: false })
                                                        .then(async collected => {
                                                            const msg = collected.first()
                                                            var Reply2 = msg.content.split(' ').slice(0).join(' ');
                                                            if (msg.content === `${Reply2}`) {
                                                                msg.delete()
                                                                const ques3 = new Discord.MessageEmbed()
                                                                    .setTitle("Question 3")
                                                                    .setDescription("What are the basic things that a DJ needs to do?")
                                                                msg5 = await msg4.edit(ques3)
                                                                const filter3 = (m) => m.author.id === msg.author.id
                                                                msg5.channel.awaitMessages(filter3, { max: 1, time: false })
                                                                    .then(async collected => {
                                                                        const msg = collected.first()
                                                                        var Reply3 = msg.content.split(' ').slice(0).join(' ');
                                                                        if (msg.content === `${Reply3}`) {
                                                                            msg.delete()
                                                                            const ques4 = new Discord.MessageEmbed()
                                                                                .setTitle("Question 4")
                                                                                .setDescription("How active are you from 1-10?")
                                                                            msg6 = await msg5.edit(ques4)
                                                                            const filter4 = (m) => m.author.id === msg.author.id
                                                                            msg6.channel.awaitMessages(filter4, { max: 1, time: false })
                                                                                .then(async collected => {
                                                                                    const msg = collected.first()
                                                                                    var Reply4 = msg.content.split(' ').slice(0).join(' ');
                                                                                    if (msg.content === `${Reply4}`) {
                                                                                        msg.delete()
                                                                                        const ques5 = new Discord.MessageEmbed()
                                                                                            .setTitle("Question 5")
                                                                                            .setDescription("Why should we deem to trust you?")
                                                                                        msg7 = await msg6.edit(ques5)
                                                                                        const filter5 = (m) => m.author.id === msg.author.id
                                                                                        msg7.channel.awaitMessages(filter5, { max: 1, time: false })
                                                                                            .then(async collected => {
                                                                                                const msg = collected.first()
                                                                                                var Reply5 = msg.content.split(' ').slice(0).join(' ');
                                                                                                if (msg.content === `${Reply5}`) {
                                                                                                    msg.delete()
                                                                                                    const ques6 = new Discord.MessageEmbed()
                                                                                                        .setTitle("Finished!")
                                                                                                        .setDescription("You have completed the application and it is being held for review. To either send or delete the application, please go to your DMs.")
                                                                                                    msg8 = await msg6.edit(ques6)
                                                                                                    msg9 = await msg.author.send("Here are all your answers, " + found.name + ". \n \n **Question 1,** Have you had experience with this job before? \n" + Reply1 + " \n \n **Question 2,** Why should we choose you over other applicants? \n" + Reply2 + " \n \n **Question 3,** What are the basic things that a DJ needs to do? \n" + Reply3 + " \n \n **Question 4,** How active are you from 1-10? \n" + Reply4 + " \n \n **Question 5,** Why should we deem to trust you? \n" + Reply5 + " \n \n **Please choose to either send or delete the application below.**")
                                                                                                    msg9.react('✅').then(r => {
                                                                                                        msg9.react('❎');
                                                                                                    });
                                                                                                    msg9.awaitReactions((reaction, user) => user.id == msg.author.id && (reaction.emoji.name == '❎' || reaction.emoji.name == '✅'),
                                                                                                        { max: 1, time: false }).then(async collected => {
                                                                                                            if (collected.first().emoji.name == '❎') {
                                                                                                                msg9.reactions.removeAll()
                                                                                                                msg9.edit("The application has not been sent.")
                                                                                                            }
                                                                                                            if (collected.first().emoji.name == '✅') {
                                                                                                                const app = new Discord.MessageEmbed()
                                                                                                                    .setTitle("New application from `" + msg.author.username + "`")
                                                                                                                    .setDescription("Answers from: " + found.name + ". \n \n **Question 1,** Have you had experience with this job before? \n" + Reply1 + " \n \n **Question 2,** Why should we choose you over other applicants? \n" + Reply2 + " \n \n **Question 3,** What are the basic things that a DJ needs to do? \n" + Reply3 + " \n \n **Question 4,** How active are you from 1-10? \n" + Reply4 + " \n \n **Question 5,** Why should we deem to trust you? \n" + Reply5)
                                                                                                                bot.channels.cache.get("771671063909761044").send(app)
                                                                                                                msg9.edit("Your application has been sent! Keep an eye on the jobs channel to see if you passed!")
                                                                                                                msg9.reactions.removeAll()
                                                                                                            }
                                                                                                        })
                                                                                                }
                                                                                            })
                                                                                    }
                                                                                })
                                                                        }
                                                                    })
                                                            }
                                                        })
                                                }
                                            })
                                    }
                                }).catch(() => {
                                    msg.reply('No reaction after 30 seconds, operation canceled');
                                    msg2.reactions.removeAll()
                                });
                        }
                    })
        } else {
            msg.delete()
            msg.author.send("You can only use the command `--apply` in the application channel (<#771665046514040833>)")
        }
    }
})
bot.on(“消息”,异步消息=>{
if(msg.content.startsWith(`${prefix}apply`){
让ban=banndarray.forEach(banked=>{
如果(msg.author.id==禁止){
msg.delete()
msg.channel.send(“您被禁止”)
}
})
如果(msg.channel.id==“77166504614040833”){
var user=msg.content.split(“”).slice(1.join(“”)
const load=new Discord.MessageEmbed()
.setTitle(“获取您的用户ID…”)
msg2=wait msg.channel.send(正在加载)
rapi.getUserIdFromUsername(用户)。然后(异步查找=>{
如果(找到===false){
msg2.编辑(“测试”)
}否则{
const found2=new Discord.MessageEmbed()
.setTitle(“找到用户ID”)
.set缩略图(找到.getAvatarBustImage)
.setDescription(“我们找到了一个链接到您帐户的用户ID。它是:“+found.ID+”。这是您吗?\n[单击此处转到配置文件](https://www.roblox.com/users/“+found.id+”/profile)\n\n***请注意,如果您使用✅ 您的ID将被存储用于阅读目的。***”)
msg2.edit(found2)
msg.delete()
msg2.react('✅').然后(r=>{
msg2.react('❎');
});
msg2.aittreactions((reaction,user)=>user.id==msg.author.id&&(reaction.emoji.name==)❎' || reaction.emoji.name=='✅'),
{max:1,time:30000})。然后(异步收集=>{
if(collected.first().emoji.name=='❎') {
msg.reply(“尚未存储ID”)
}
if(collected.first().emoji.name=='✅') {
推送(`${found.id}|${found.name}`)
console.log(found.id+“| |”+found.name)
bot.channels.cache.get(“771406620570943548”).send(“新ID推送到表中。使用`idarray`查看完整列表。\n用户的Roblox ID:“+found.ID+”\n Roblox名称:”+found.Name)
const check=new Discord.MessageEmbed()
.setTitle(“成功”)
.setDescription(“您的ID现在已保存。请打开此应用程序的DMs,以便我可以对您进行DM。\n问题1:\n您以前有过此工作的经验吗?”)
msg3=等待msg2。编辑(检查)
msg2.reactions.removeAll()
常量筛选器=(m)=>m.author.id==msg.author.id
等待消息(筛选器,{max:1,time:false})
。然后(异步收集=>{
const msg=collected.first()
var Reply1=msg.content.split(“”).slice(0).join(“”);
如果(msg.content==`${Reply1}`){
msg.delete()
const ques2=new Discord.MessageEmbed()
.setTitle(“问题2”)
.setDescription(“为什么我们应该选择您而不是其他申请人?”)
msg4=等待msg3.edit(ques2)
常量过滤器2=(m)=>m.author.id==msg.author.id
msg4.channel.awaitMessages(filter2,{max:1,time:false})
。然后(异步收集=>{
const msg=collected.first()
var Reply2=msg.content.split(“”).slice(0).join(“”);
如果(msg.content==`${Reply2}`){
msg.delete()
const ques3=new Discord.MessageEmbed()
.setTitle(“问题3”)
.setDescription(“DJ需要做的基本事情是什么?”)
msg5=等待msg4.edit(ques3)
常量过滤器3=(m)=>m.author.id==msg.author.id
等待消息(filter3,{max:1,time:false})
。然后(异步收集=>{
const msg=collected.first()
var Reply3=msg.content.split(“”).slice(0).join(“”);
如果(msg.content==`${Reply3}`){
msg.delete()