最近,我一直在试图做一个不和谐的机器人。一切都很顺利,直到我运行start.bat文件。 当我运行它,我得到这个:为什么我的不和谐机器人工作?
client.on('ready',() => {
^
SyntaxError: Unexpected token)
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
下面是我用得到机器人掉在地上的示例代码:
const Discord = require("discord.js");
const client = new Discord.Client();
client.login('MzEzNzc1NzUwOTQxNTA3NTg0.C_-ilQ.vJyMW_Q2PjLLntwgifRRCnjPw88')
client.on('ready',() => {
console.log(`Logged in as ${client.user.username}!`);
});
client.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('Pong!');
}
});
client.login('token');
而且我的start.bat文件:
@echo off
node bot.js
PAUSE
最后,这里的版本信息:
2 info using [email protected]
3 info using [email protected]
任何线索这意味着什么,以及我如何解决它?
请发布[完整的相关代码](https://stackoverflow.com/help/mcve)和您的Node.js版本;您发布的错误消息确实表明您有语法错误,但实际确定问题的可能性还不够。 – Frxstrem
这是一个语法错误,这意味着它不知道如何解析你的代码。你使用的是什么版本的Node?它使用常规的匿名函数而不是简写工作吗? – solarc