Migrate eval command
This commit is contained in:
parent
c62488aa63
commit
acedbffdad
3 changed files with 33 additions and 25 deletions
32
src/commands/eval.ts
Normal file
32
src/commands/eval.ts
Normal 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();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue