Ask coding questions

← Back to all posts
Does anyone else have this issue?
Primebreaker

Ever since I updated my discord bot from discord.js version 12 to discord.js version 13, it has not allowed me to start my bot. It logs an error that points to a file within node_modules that I cannot see.

Error: SyntaxError: Unexpected token '?'

Does anyone have a fix or know why this is happening?

Answered by JustCoding123 [earned 5 cycles]
View Answer
Voters
Primebreaker
Comments
hotnewtop
JustCoding123

You can't use discord.js v13 in a normal node repl. Type npm i [email protected] to downgrade the discord.js version back to v12.

Primebreaker

@JustCoding123 Thank you! Do you know what I need to run discord.js v13?

JustCoding123

@Primebreaker Fork this repl then move your current code into index.js.

Primebreaker

@JustCoding123 I forked the repl and re installed v13 and it didn't work.

JustCoding123

@Primebreaker Whats the error message?

Primebreaker

@JustCoding123

/home/runner/Bot-2/node_modules/discord.js/src/rest/RESTManager.js:32
const token = this.client.token ?? this.client.accessToken;
^

SyntaxError: Unexpected token '?'

JustCoding123

@Primebreaker Did you move your code into the forked repl?

Primebreaker

@JustCoding123 It automatically does that.

JustCoding123

@Primebreaker I looked at your profile and you didn't fork the repl.

Primebreaker

@JustCoding123 Just cleaned up my repl's that i didn't need, check now.

ShluffyMonster

@Primebreaker seems to have not been forked

JustCoding123

@Primebreaker How are you forking the repl? Because you only have node js repls and the repl I sent is a nix repl.

Primebreaker

@JustCoding123 I clicked on the three vertical dots next to the repl and clicked "fork"

JustCoding123

@Primebreaker Ok. I found this tutorial on youtube (not mine). Just follow the steps and it should work.

Primebreaker

@JustCoding123 Hey, finished following the tutorial. It works however, whenever I try to do a command it sends a series of errors. one including:

(node:1358) DeprecationWarning: The message event is deprecated. Use messageCreate instead
(Use node --trace-deprecation ... to show where the warning was created)
/home/runner/Primer/node_modules/discord.js/src/rest/RequestHandler.js:298
throw new DiscordAPIError(data, res.status, request);
^

DiscordAPIError: Cannot send an empty message

Primebreaker

@JustCoding123 Nevermind, just realised it's because of the new features of v13. I believe all is good, thank your for you time.

JustCoding123

@Primebreaker Sorry I was not online at the time. You're welcome