javascript - 为什么我的不和谐机器人的脚本显示“未捕获的语法错误:意外标识符”?
问题描述
我是创建不和谐机器人的新手,我制作了这个 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');
解决方案
推荐阅读
- node.js - 运行几个小时后,Socket.io / Nodejs 无法从服务器发送数据
- reactjs - 在 reactjs 中实现身份验证时面临的问题
- sql - 如何使用 SQL Server 查询将字符和数字与单词分开
- mongodb - 如何为 mongodb 查询聚合数据?
- c# - BraintreePayments API 查询给定日期的交易
- .net - 我们可以在 GCP VM 实例中设置 .Net 开发环境吗
- angular - htmlInputElement 中的错误 算术运算的左侧必须是 any、num 类型
- java - while 和 for 循环之间在计算上有什么区别吗?
- javascript - Highcharts如何在不设置最小值或最大值的情况下启用滚动条
- apache - 在多个 docker 容器中运行的负载均衡应用服务器