Reputation: 43
I recently got a weird error with my bot discord. discord.js seems to crash whenever I run my bot :
[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...
This started to happen after I updated my discord.js and node module so I think it's not really a code issue and more just me who fucked up the update. I'm new to discord.js and node, so it's more than probable that this is something really simple.
I tried to start it with node instead of nodemon but I got this:
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'
}
I'm a little lost (I mean a lot) with all of that and I couldn't really find anything on the internet.
Here is my dependencies if it can help :
{
"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": "[email protected]",
"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"
}
}
Thank you for taking the time to read this and please forgive any spelling mistakes.
Upvotes: 0
Views: 3146
Reputation: 8718
If you check Discord.js's upgrade guide, it mentions that it requires Node.js v16.6 or higher. According to Node.green, the nullish coalescing operator is only supported in Node.js v14.5.0 or higher, so I assume your mistake is not properly upgrading Node.js. I did notice you have node
in your dependencies? It should be in engines, and that won't upgrade Node.js, it'll only warn you if you're using the wrong version. Properly install Node.js v16.6 or higher.
You could technically use the node
NPM module to run a different version of Node.js but that seems weird. It does fix the problem with your nullish coalescing operator though. The cause for your second error is also explained in the upgrade guide, this section to be precise.
Upvotes: 1