I'm using discord.js. I have an eval command (code:
if (cmd === `${prefix}eval`) {
if (message.author.id !== "627835075064627221") return;
function clean(text) {
if (typeof (text) === "string")
return text.replace(/`/g, "`" + String.fromCharCode(8203)).replace(/@/g, "@" + String.fromCharCode(8203));
else
return text;
}
try {
const code = message.content.split(" ").slice(1).join(" ");
let evaled = eval(code);
if (typeof evaled !== "string")
evaled = require("util").inspect(evaled)
let evalCode = new Discord.MessageEmbed()
.setTitle("**EVAL**")
.setDescription(clean(evaled), { code: "xl" })
.setColor("RANDOM")
.setFooter("Spood's Lounge | Eval")
message.channel.send({ embed: evalCode });
} catch (err) {
message.channel.send(`\`ERROR\` \`\`\`xl\n${clean(err)}\n\`\`\``);
}
}
and when I do something to eval message.reply("hello world!")
it just returns Promise { < Pending > }
. When I try to do other things like eval console.log("hello world!")
it returns undefined.
How can I fix it so it returns the actual value?