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

317
Vistas
SyntaxError : Unexepected token 'export'

So yeah I'll just get to the point, an error gets thrown at me, while I don't know what to do, it's quite weird because the code is fine there is just something wrong with what I'm saying here. Here is where the problem is:

const { codeBlock } = require("@discordjs/builders");
const { ExplicitContentFilterLevels } = require("discord.js/typings/enums.d.ts");

async function clean(client, text) {
  if (text && text.container.name == "Promise")
    text = await text;
  if (typeof text !== "string")
    text = require("util").inspect(text, {depth: 1});

  text = text
    .replace(/`/g, "`" + String.fromCharCode(8023))
    .replace(/@/g, "@" + String.fromCharCode(8023));

  text = text.replaceAll(client.token, "[REDACTED]");

  return text;
}

exports.run = async (client, message, args, level) => {
  const code = args.join(" ");
  const evaled = eval(code);
  const cleaned = await clean(client, evaled);
  message.channel.send(codeBlock("js", cleaned));
};

exports.conf = {
  enabled: true,
  guildOnly: false,
  aliases: [],
  permLevel: "Bot Owner"
};

exports.help = {
  name: "eval",
  category: "System",
  description: "Evaluates arbitrary javascript.",
  usage: "eval [...code]"
};

here is where the error gets thrown at me:

ERROR Unhandled rejection: SyntaxError: Unexpected token 'export' 
C:\Users\emilb\OneDrive\Desktop\Tap\node_modules\discord.js\typings\enums.d.ts:4
export const enum ActivityTypes {
^^^^^^

SyntaxError: Unexpected token 'export'
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1031:15)
    at Module._compile (node:internal/modules/cjs/loader:1065:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:94:18)
    at Object.<anonymous> (C:\Users\emilb\OneDrive\Desktop\Tap\commands\eval.js:2:41)
about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You are not supposed to import a *.d.ts file. Those files are TypeScript definition files, which are there to help you IDE offer better type hints.

Change the import to this:

const { ExplicitContentFilterLevels } = require("discord.js/src/util/Constants");

Or even better change it to the line below, because that way you are not tied to the internal structure of the Discord package.

const { Constants: { ExplicitContentFilterLevels } } = require('discord.js');
about 4 years ago · Juan Pablo Isaza Denunciar

0

You can't import from a Typescript (.ts) file when your project is Javascript. (Not to mention you shouldn't import from .d.ts files anyway.)

Since you're not using ExplicitContentFilterLevels, just remove the line attempting to import it.

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