首页 > 解决方案 > 为什么我的不和谐机器人的脚本显示“未捕获的语法错误:意外标识符”?

问题描述

我是创建不和谐机器人的新手,我制作了这个 hello world 代码,但它不起作用。在 node.js 中,我执行了“nodemon --inspect index.js”,但它显示“未捕获的语法错误:意外标识符”。我已经安装了 nodemon 和 discord.js,还从 discord.js.org 复制了代码,但它仍然不能正常工作。我应该怎么做才能让它工作?

const Discord = require('discord.js');
const client = new Discord.Client();

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('message', msg => {
  if (msg.content === 'ping') {
    msg.reply('Pong!');
  }
});

client.login('token');

标签: javascriptdiscord.js

解决方案


推荐阅读