好吧,所以我观看了一个有关如何执行Eval命令的youtube视频(源代码:https://github.com/MenuDocs/Discord.JS-Tutorial/blob/Episode-21/commands/owner/eval.js),他们可以在视频中eval message.author.id
进行调试。而在我的机器人中,聊天时出现错误:Error while evaluating: Unexpected identifier
(https://imgur.com/a/1NWuWEy *请注意,我使用2'a使其与我的机器人保持独立,从而减少了重复消息)。
case 'evaal':
const args = message.content.substring(PREFIX.length).trim().split(" ");
const ownerID = '285198963722944514';
if(message.author.id == ownerID) {
try {
let toEval = args.join(" ")
let evaluated = inspect(eval(toEval, { depth: 0 }));
if (!toEval) {
return message.channel.send("Error while evaluating: \`cannot evaluate air\`!");
} else {
let hrStart = process.hrtime()
let hrDiff;
hrDiff = process.hrtime(hrStart);
return message.channel.send(`*Executed in ${hrDiff[0] > 0 ? `${hrDiff[0]}s ` : ''}${hrDiff[1] / 1000000}ms.*\n\`\`\`javascript\n${evaluated}\n\`\`\``, { maxLength: 1900 })
}
} catch (e) {
return message.channel.send(`Error while evaluating: \`${e.message}\``)
}
} else {
return message.reply('You are not allowed to use this command. (Owner Only)').then(m => m.delete(5000))
}
break;
如imgur图像中的上面所链接,该bot会响应,但只会显示错误消息。我希望它能告诉我消息的作者ID(我)。