【问题标题】:Why does it output an error: "Unexpected token: '?' " in discord.js replit? [duplicate]为什么会输出错误:“Unexpected token: '?' “在discord.js 中复制? [复制]
【发布时间】:2021-08-16 05:43:16
【问题描述】:

我想使用 replit 来制作我的 discord 机器人。我在 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"]);

不知何故,它输出了一个错误。它指出: 常量令牌 = this.client.token ?? this.client.accessToken 语法错误:意外标记:'?'

谢谢你, 保罗10

【问题讨论】:

标签: discord.js


【解决方案1】:

这是因为 repl.it 使用了不支持 ?? 运算符的旧版 Node.js。我建议遵循本教程:

https://replit.com/talk/learn/Nodejs-14-on-replit/85501

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多