discord.js - 为什么会输出错误:“Unexpected token: '?' “在discord.js 中复制?
问题描述
我想使用 replit 来制作我的不和谐机器人。我在 node.js repli 上安装了 discord.js。我在 index.js 中插入了这段代码:
const { Client, Intents } = require("discord.js");
const client = new Client({
intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES],
});
client.on("ready", () => {
console.log("If you can see this in the console when you run it on replit, I will be shocked lol")
});
client.login(process.env["BOT_TOKEN"]);
不知何故,它输出了一个错误。它指出: const token = this.client.token ?? this.client.accessToken 语法错误:意外的令牌:'?'
谢谢你,保罗10
解决方案
这是因为 repl.it 使用了不支持??
操作符的旧版 Node.js。我建议遵循本教程:
推荐阅读
- python-3.x - Python将单个字符串元素与多个字符串元素结合起来
- ios - 如何使用swift向haishinkit添加多个音频输入(CMSampleBuffer)?
- git - NPM 安装/更新:无需使用 Git 存储库更改 package.json 即可获取最新版本
- c++ - 如何在 C++ 中编写随机大写字符生成器?
- spring - DefaultJmsListenerContainer 使用 BeanFactoryPostProcessor
- c# - 事件处理程序更新属性时 WPF 绑定不起作用
- antlr - Antlr 生成的文件
- c++ - 如何计算包含位集字段的结构的大小
- spring - spring-cloud-loabalancer 配置静态服务器列表
- python - 搜索不包含某些字符的字符串