【发布时间】:2020-12-09 14:51:30
【问题描述】:
我在尝试添加 else if() 函数时遇到了问题(我认为这就是它的名称),但一旦我这样做,就会遇到烦人的错误!
这是原始代码,
if(command === 'clue1') {
client.commands.get('clue1').execute(message, client);
await configDB.updateOne({
Clue_1: "True"
})
const collection = db.collection('clues')
if(collection.find({ _id: ("ID HERE") }, {Clue1_Status: "True"}, (err, data) => {
if (err) console.error(err)
return !data;
})
)
return
collection.find({ _id: ("ID HERE") }, {Clue1_Status: "False"}, async (err, data) => {
if (err) console.error(err)
if (data) {
const embed1 = new MessageEmbed()
.setTitle(`:partying_face: ${message.author.tag}` + " Just solved `Clue 1` :partying_face:")
.setColor(0xFFFF00)
client.channels.fetch("Channel ID")
.then(message =>
message.send(embed1)
)
await configDB1.updateOne({
Clue1_Status : "True"
})
}
})
}
这是我要更改的代码:
if(command === 'clue1') {
client.commands.get('clue1').execute(message, client);
await configDB.updateOne({
Clue_1: "True"
})
const collection = db.collection('clues')
if(collection.find({ _id: ("ID HERE") }, {Clue1_Status: "True"}, (err, data) => {
if (err) console.error(err)
return !data;
})
)
return
collection.find({ _id: ("ID HERE") }, {Clue1_Status: "False"}, async (err, data) => {
if (err) console.error(err)
if (data) {
const embed1 = new MessageEmbed()
.setTitle(`:partying_face: ${message.author.tag}` + " Just solved `Clue 1` :partying_face:")
.setColor(0xFFFF00)
client.channels.fetch("Channel ID")
.then(message =>
message.send(embed1)
)
await configDB1.updateOne({
Clue1_Status : "True"
})
}
})
)}
但我得到SyntaxError: Unexpected token '}'
(出于隐私原因,我删除了一些代码(ID 等))
【问题讨论】:
标签: node.js mongodb discord.js