Skip to content
Sign upLog in
← Back to Community

Does anyone else have this issue?

Profile icon
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
Profile icon
Facebokma
Profile icon
Primebreaker
Comments
hotnewtop
Profile icon
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.

Profile icon
Primebreaker

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

Profile icon
JustCoding123

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

Profile icon
Primebreaker

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

Profile icon
JustCoding123

@Primebreaker
Whats the error message?

Profile icon
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 '?'

Profile icon
JustCoding123

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

Profile icon
Primebreaker

@JustCoding123
It automatically does that.

Profile icon
JustCoding123

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

Profile icon
Primebreaker

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

Profile icon
ShluffyMonster

@Primebreaker
seems to have not been forked

Profile icon
JustCoding123

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

Profile icon
Primebreaker

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

Profile icon
JustCoding123

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

Profile icon
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

Profile icon
Primebreaker

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

Profile icon
JustCoding123

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

Profile icon
NanduWasTaken

@Primebreaker

Look at my GitHub respository
To run discord.js v13 you need node.js v16.6 or higher then that
you have to import this repository to your repl and do your things in the index.js
Don't touch other things if you don't know what you are doing

Cheers Nandu

Profile icon
NanduWasTaken

@NanduWasTaken

This repository is especially made for replit

https://github.com/NanduWasTaken/Node.js-16-on-replit