Migrate eval command

This commit is contained in:
Ethan Lane 2021-12-02 13:15:08 +00:00
parent c62488aa63
commit acedbffdad
Signed by: Vylpes
GPG key ID: EED233CC06D12504
3 changed files with 33 additions and 25 deletions

32
src/commands/eval.ts Normal file
View file

@ -0,0 +1,32 @@
import { Command, ICommandContext } from "vylbot-core";
import ErrorEmbed from "../helpers/ErrorEmbed";
import PublicEmbed from "../helpers/PublicEmbed";
export default class Evaluate extends Command {
constructor() {
super();
super._category = "Owner";
}
public override execute(context: ICommandContext) {
if (context.message.author.id != process.env.BOT_OWNERID) {
return;
}
const stmt = context.args;
console.log(`Eval Statement: ${stmt.join(" ")}`);
try {
const result = eval(stmt.join(" "));
const embed = new PublicEmbed(context, "", result);
embed.SendToCurrentChannel();
}
catch (err: any) {
const errorEmbed = new ErrorEmbed(context, err);
errorEmbed.SendToCurrentChannel();
}
}
}