Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

207
Vistas
agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });

So I'm learning how to make bot on discord using discord.js

this is my bot.js

require("dotenv").config();
const { Client } = require('discord.js');
const client = new Client();
client.login(process.env.DISCORD_TOKEN_KEY);

this is my package.json file:

{
  "name": "aibot",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node ./src/bot.js",
    "dev": "nodemon ./src/bot.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "discord.js": "^13.2.0",
    "dotenv": "^10.0.0"
  }
}

So when I run node ./src/bot.js I am getting this error:

PS E:\RIYA\AIBOT> node -v
v14.18.0

PS E:\RIYA\AIBOT> node ./src/bot.js
E:\RIYA\AIBOT\node_modules\discord.js\src\rest\APIRequest.js:33
    agent ??= new https.Agent({ ...this.client.options.http.agent, keepAlive: true });
          ^^^

SyntaxError: Unexpected token '??='
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (E:\RIYA\AIBOT\node_modules\discord.js\src\rest\RESTManager.js:4:20)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)

What shall I do? I don't know much about NodeJs and I'm not able to figure out how to solve this issue.

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You have to update node.js to v16.6 or later, as per the docs (scroll down to "Installation").

about 4 years ago · Juan Pablo Isaza Denunciar

0

You need to update your Node to version 16.6.0 or newer to work and modify your

2nd and 3rd lines

of code to:

const { Client, Intents } = require('discord.js');
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });

To prevent

[Symbol(code)]: 'CLIENT_MISSING_INTENTS' error

Read More from the documentation https://discord.js.org/#/docs/main/stable/general/welcome

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda