Eval命令根本不起作用,但不报错

问题描述 投票:0回答:1

我正在尝试为我的机器人创建一个 eval 命令。它不会出错,但不会向控制台或不和谐频道发送消息。这是我的评估代码:

const clean = async (client, text) => {
  if (text && text.constructor.name == "Promise")
    text = await text;
  if (typeof text !== "string")
    text = require("util").inspect(text, { depth: 1 });
  text = text
    .replace(/`/g, "`" + String.fromCharCode(8203))
      .replace(/@/g, "@" + String.fromCharCode(8203));
  text = text.replaceAll(client.token, "[REDACTED]");
  return text;
}

client.on("messageCreate", async (message) => {
  const args = message.content.split(" ").slice(1);

  if (message.content.startsWith(`${p}eval`)) {
    if (message.author.id !== 821682594830614578) {
      return;
    }
    
    try {
      const evaled = eval(args.join(" "));
      const cleaned = await clean(client, evaled);

      message.channel.send(`\`\`\`js\n${cleaned}\n\`\`\``);
    } catch (err) {
      message.channel.send(`\`ERROR\` \`\`\`xl\n${cleaned}\n\`\`\``);
    }

  }

});
discord discord.js eval
1个回答
0
投票

看起来您输入了一个数字作为您的 ID...Discord.js ID 位于字符串中,因此您应该将您的 ID 放入字符串中。

    if (message.author.id !== "821682594830614578") {
      return;
    }
© www.soinside.com 2019 - 2024. All rights reserved.