所以是的,我会直截了当,一个错误被抛出,而我不知道该怎么做,这很奇怪,因为代码很好,只是我在这里说的有问题。这是问题所在:
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]"
};
这是向我抛出错误的地方:
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)