我对于为什么这段代码无法正常工作感到非常困惑。这是我的代码:
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>)")
}
}
})
在此脚本中,它检查是否有人被禁止,但如果有人被禁止,该命令将继续。我确实收到一条错误消息:DiscordAPIError:未知消息。我真的很困惑,因为我在自己制作的其他机器人中使用了这种方法。有人可以帮我吗?