Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

241
Views
SyntaxError: Identifier 'client' has already been declared

im tryna make a discord bot. whenever i try to run it with cmd i get this:

error in cmd:

C:\Users\kaalj\OneDrive\Desktop\Bot>node main.js
C:\Users\kaalj\OneDrive\Desktop\Bot\main.js:7
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
      ^

SyntaxError: Identifier 'client' has already been declared
←[90m    at wrapSafe (internal/modules/cjs/loader.js:988:16)←[39m
←[90m    at Module._compile (internal/modules/cjs/loader.js:1036:27)←[39m
←[90m    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)←[39m
←[90m    at Module.load (internal/modules/cjs/loader.js:937:32)←[39m
←[90m    at Function.Module._load (internal/modules/cjs/loader.js:778:12)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)←[39m
←[90m    at internal/main/run_main_module.js:17:47←[39m

the code i got this far is: Package.json

{
  "name": "gerda",
  "version": "1.0.0",
  "description": "Gerda",
  "main": "= main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "Jordy",
  "license": "ISC",
  "dependencies": {
    "discord.js": "^13.1.0"
  }
}

main.js:

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

const client = new Discord.Client();

const { Client, Intents } = require('discord.js');

const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });

client.once('ready', () => {
  console.log('Gerda is er');
});

client.login("Token");

anyone knows what i have to do to make it run? (in my code i actually have my token filled in)

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

as you can see on lines: 3 and 7 , on both you declared const which is called: client.

it is that simple.

about 4 years ago · Juan Pablo Isaza Report

0

You just need to remove the client declared at line number 3. You have already handled it in line 7 in detail. So delete line 3 and you're good.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!