Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

315
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda