【发布时间】:2021-10-12 17:00:46
【问题描述】:
最近我的机器人不和谐出现了一个奇怪的错误。每当我运行我的机器人时,discord.js 似乎都会崩溃:
[nodemon] 2.0.12
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node ./src/index.js`
C:\Users\myname\Documents\Loisir\Dev\Discord_Bots\Aura-discord\bot\node_modules\discord.js\src\rest\RESTManager.js:32
const token = this.client.token ?? this.client.accessToken;
^
SyntaxError: Unexpected token '?'
at wrapSafe (internal/modules/cjs/loader.js:1070:16)
at Module._compile (internal/modules/cjs/loader.js:1120:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Module.require (internal/modules/cjs/loader.js:1042:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (C:\Users\hugo\Documents\Loisir\Dev\Discord_Bots\Aura-discord\bot\node_modules\discord.js\src\client\BaseClient.js:4:21)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
[nodemon] app crashed - waiting for file changes before starting...
这在我更新了我的 discord.js 和 node 模块后开始发生,所以我认为这不是真正的代码问题,而更多的是我搞砸了更新。我是 discord.js 和 node 的新手,所以这很可能非常简单。
我尝试使用 node 而不是 nodemon 来启动它,但我得到了这个:
C:\Users\hugo\Documents\Loisir\Dev\Discord_Bots\Aura-discord\bot\node_modules\discord.js\src\client\Client.js:544
throw new TypeError('CLIENT_MISSING_INTENTS');
^
TypeError [CLIENT_MISSING_INTENTS]: Valid intents must be provided for the Client.
at Client._validateOptions (C:\Users\hugo\Documents\Loisir\Dev\Discord_Bots\Aura-discord\bot\node_modules\discord.js\src\client\Client.js:544:13)
at new Client (C:\Users\hugo\Documents\Loisir\Dev\Discord_Bots\Aura-discord\bot\node_modules\discord.js\src\client\Client.js:73:10)
at Object.<anonymous> (C:\Users\hugo\Documents\Loisir\Dev\Discord_Bots\Aura-discord\bot\src\index.js:5:16)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
at node:internal/main/run_main_module:17:47 {
[Symbol(code)]: 'CLIENT_MISSING_INTENTS'
}
我对这一切有点迷茫(我的意思是很多),我在互联网上找不到任何东西。
如果有帮助,这是我的依赖项:
{
"name": "Aura-discord",
"version": "0.0.1",
"description": "Aura is a bot specialized in the creation and management of tournaments on discord.",
"main": "index.js",
"scripts": {
"dev": "nodemon ./src/index.js",
"start": "node ./src/index.js",
"build": ""
},
"keywords": [],
"author": "myName",
"mail": "hberferf@auradiscord.bot",
"website": "http://aura-discord.bot",
"license": "ISC",
"dependencies": {
"discord.js": "^13.0.1",
"mongoose": "^5.13.5",
"node": "^16.6.1"
},
"devDependencies": {
"nodemon": "^2.0.12"
}
}
感谢您抽出宝贵时间阅读本文,如有拼写错误,请原谅。
【问题讨论】:
-
您的节点版本似乎不支持Nullish coalescing operator?确保使用 v14+
标签: javascript node.js discord.js node-modules