Недавно я получил странную ошибку с дискордом моего бота. 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"
}
}
Спасибо, что нашли время, чтобы прочитать это, и, пожалуйста, простите любые орфографические ошибки.
Ваша версия узла не поддерживает нулевой оператор объединения? Обязательно используйте v14+