【问题标题】:I got this error when I run discord.js bot [duplicate]运行 discord.js bot 时出现此错误 [重复]
【发布时间】:2021-12-20 12:44:39
【问题描述】:

当我使用 discord.js 运行 discord bot 时

[my\path\discord.js\bot]
> node bot.js
C:\Users\username\node_modules\discord.js\src\rest\APIRequest.js:33
    agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
          ^^^

SyntaxError: Unexpected token '??='
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (C:\Users\username\node_modules\discord.js\src\rest\RESTManager.js:4:20)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

[my\path\discord.js\bot]

>

我认为是休息客户端语法错误 我该如何解决?

【问题讨论】:

  • 嗯兄弟,你在用 discord.js v13 吗?
  • 发送您的代码...

标签: rest discord.js


【解决方案1】:

假设这是 Discord.js v13,您需要使用 Node 16.6.0+,如 docs 中所述。您收到的错误很可能是由于您的 Node 版本低于该版本,因为如果您使用的是正确的 node 版本,??= 应该可以工作。

Logical nullish assigment (??=) 对于 Node 来说相对较新(根据node.green 是 15.14.0),您需要将其更新到至少 16.6.0 才能使 Discord.js v13 完全发挥作用。

【讨论】:

    猜你喜欢
    • 2016-11-27
    • 2020-12-04
    • 2022-01-20
    • 2021-06-17
    • 1970-01-01
    • 2019-04-05
    • 1970-01-01
    • 2020-11-26
    • 1970-01-01
    相关资源
    最近更新 更多