I need help in node .js idk whts wrong in it


const Discord = require("discord.js")
const client = new Discord.Client()

client.on ("ready", () => {
  console.log ('Logged in as ')

client.on("message", msg => {
  if (msg.content === "ping") {


out put
const token = this.client.token ?? this.client.accessToken;

SyntaxError: Unexpected token ‘?’

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Looking at the docs the token you pass to login is supposed to be a string. Not sure if that is the problem or not, but I would still try passing it a string.

i didnt get you :sweat_smile:

Use a String value for the token.


not worked :frowning_face: . . . . . … . . .

If you are coding this on Replit you have to downgrade the discord version. Node 16.6 or higher is required for discordjs version 13.

i have a problem too,
first install old version of Discord js in console type npm i discord.js.old@11.6.4

in your script change const Discord = require('discord.js') for

const Discord = require('discord.js.old')

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.