你好(我对编程很陌生!)
每当我尝试在CMD中运行我的机器人时,我都会不断收到此错误消息(如下)。(向下滚动查看代码,错误和内容),我对此感到非常困惑!
我尝试通过移除;
来修复它,但是那没有用,它告诉我)
是意外的,但是当我移除)
时它告诉我需要它!
代码块一:
// Runs on bot start
bot.on('ready', () => {
// Now we post into the console that the bot has been turned on.
console.log('Bot turned on in the CMD')
});
代码块二:(删除分号)
// Runs on bot start
bot.on('ready', () => {
// Now we post into the console that the bot has been turned on.
console.log('Bot turned on in the CMD')
})
代码块三:
bot.on('ready', () => {
// Now we post into the console that the bot has been turned on.
console.log('Bot turned on in the CMD')
}
预期结果:机器人打开,然后在CMD中发送一条消息以达到此效果。
Error #1 (See code block 1 to find the code)
`C:\Users\xgoul\OneDrive\Desktop\Discord Bot\app.js:74
});
^
SyntaxError: Unexpected end of input
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)`
Error #2 (See code block 2 to find the code)
`C:\Users\xgoul\OneDrive\Desktop\Discord Bot\app.js:74
})
^
SyntaxError: Unexpected end of input
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)`
Error #3 (See code block 3 to find the code)
`C:\Users\XXXX\OneDrive\Desktop\Discord Bot\app.js:74
}
^
SyntaxError: missing ) after argument list
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)`
代码块1是正确的,它返回的输入意外结束,因为您必须包括一个return语句。
// Runs on bot start
bot.on('ready', () => {
// Now we post into the console that the bot has been turned on.
console.log('Bot turned on in the CMD');
return('whatever');
});