Migrate eval command
This commit is contained in:
parent
c62488aa63
commit
acedbffdad
3 changed files with 33 additions and 25 deletions
|
@ -11,6 +11,7 @@ BOT_PREFIX=v!
|
|||
BOT_VER=3.0
|
||||
BOT_AUTHOR=Vylpes
|
||||
BOT_DATE=28 Nov 2021
|
||||
BOT_OWNERID=147392775707426816
|
||||
|
||||
CORE_VER=2.0.2
|
||||
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
const { command } = require('vylbot-core');
|
||||
const { MessageEmbed } = require('discord.js');
|
||||
|
||||
class evaluate extends command {
|
||||
constructor() {
|
||||
super("evaluate");
|
||||
super.description = "Evaluates an expression";
|
||||
super.category = "Administration";
|
||||
super.requiredConfigs = "ownerid";
|
||||
}
|
||||
|
||||
evaluate(context) {
|
||||
if (context.message.author.id == context.client.config.eval.ownerid) {
|
||||
const result = eval(context.arguments.join(" "));
|
||||
|
||||
const embed = new MessageEmbed()
|
||||
.setDescription(result)
|
||||
.setColor(0x3050ba);
|
||||
|
||||
context.message.channel.send(embed);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = evaluate;
|
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…
Reference in a new issue