2022-08-14 05:51:45 -04:00
|
|
|
/* eslint-disable max-len */
|
2022-10-14 04:46:41 -04:00
|
|
|
const {MessageEmbed} = require('discord.js');
|
2022-08-14 05:51:45 -04:00
|
|
|
const {VM} = require('vm2');
|
|
|
|
const axios = require('axios');
|
|
|
|
const util = require('util');
|
|
|
|
const querystring = require('querystring');
|
|
|
|
const {stylize} = require('../util/colors/minecraft');
|
|
|
|
module.exports = {
|
|
|
|
name: 'eval',
|
|
|
|
alias: [],
|
|
|
|
description: 'Safe eval 100% secure!!!',
|
|
|
|
trusted: 0,
|
2022-08-25 06:04:43 -04:00
|
|
|
usage: '<run|reset|server> <code>',
|
2022-11-06 03:30:25 -05:00
|
|
|
execute: function(bot, username, usernameraw, sender, prefix, args, config) {
|
2022-11-07 07:26:38 -05:00
|
|
|
if (args[0] === 'run') {
|
2022-08-14 05:51:45 -04:00
|
|
|
try {
|
2022-11-07 06:30:37 -05:00
|
|
|
bot.tellraw('@a', {text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 1900)});
|
2022-08-14 05:51:45 -04:00
|
|
|
} catch (err) {
|
2022-11-07 06:30:37 -05:00
|
|
|
bot.tellraw('@a', {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'});
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
|
|
|
}
|
2022-11-07 07:26:38 -05:00
|
|
|
if (args[0] === 'reset') {
|
2022-08-14 05:51:45 -04:00
|
|
|
bot.vm = new VM(bot.vmoptions);
|
|
|
|
}
|
2022-11-07 07:26:38 -05:00
|
|
|
if (args[0] === 'server') {
|
2022-08-14 05:51:45 -04:00
|
|
|
axios
|
2022-10-14 04:46:41 -04:00
|
|
|
.post(config.eval.serverUrl, querystring.stringify({
|
2022-08-14 05:51:45 -04:00
|
|
|
html: false,
|
|
|
|
showErrorMsg: false,
|
|
|
|
colors: 'minecraft',
|
|
|
|
code: args[1],
|
|
|
|
})).then((res) => {
|
2022-11-07 06:30:37 -05:00
|
|
|
bot.tellraw('@a', {text: `${res.data}`});
|
2022-10-14 04:46:41 -04:00
|
|
|
}).catch((err) => {
|
2022-11-07 06:30:37 -05:00
|
|
|
bot.tellraw('@a', {text: `${err}`, color: 'red'});
|
2022-08-14 05:51:45 -04:00
|
|
|
});
|
|
|
|
}
|
2022-11-07 07:26:38 -05:00
|
|
|
// if (args[0] === 'dineval') {
|
2022-08-25 06:04:43 -04:00
|
|
|
// axios
|
|
|
|
// .get('https://eval.dinhero21.repl.co', {
|
|
|
|
// headers: {
|
|
|
|
// data: args[1],
|
|
|
|
// colors: 'minecraft',
|
|
|
|
// },
|
|
|
|
// }).then((res) => {
|
2022-11-07 06:30:37 -05:00
|
|
|
// bot.tellraw('@a', {text: `${res.data}`}));
|
2022-08-25 06:04:43 -04:00
|
|
|
// }).catch((e) => {
|
2022-11-07 06:30:37 -05:00
|
|
|
// bot.tellraw('@a', {text: `${e}`, color: 'red'});
|
2022-08-25 06:04:43 -04:00
|
|
|
// });
|
|
|
|
// }
|
2022-08-14 05:51:45 -04:00
|
|
|
},
|
2022-11-06 03:30:25 -05:00
|
|
|
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
|
2022-11-07 07:26:38 -05:00
|
|
|
if (args[0] === 'run') {
|
2022-10-14 04:46:41 -04:00
|
|
|
try {
|
|
|
|
const Embed = new MessageEmbed()
|
|
|
|
.setColor('#FFFF00')
|
|
|
|
.setTitle('Output')
|
|
|
|
.setDescription(`\`\`\`${util.inspect(bot.vm.run(args.slice(1).join(' ')))}\`\`\``);
|
|
|
|
channeldc.send({embeds: [Embed]});
|
|
|
|
} catch (err) {
|
|
|
|
throw err;
|
|
|
|
}
|
2022-11-07 08:08:29 -05:00
|
|
|
} else if (args[0] === 'reset') {
|
2022-10-14 04:46:41 -04:00
|
|
|
bot.vm = new VM(bot.vmoptions);
|
2022-11-07 08:08:29 -05:00
|
|
|
} else if (args[0] === 'server') {
|
2022-10-14 04:46:41 -04:00
|
|
|
axios
|
|
|
|
.post(config.eval.serverUrl, querystring.stringify({
|
|
|
|
html: false,
|
|
|
|
showErrorMsg: false,
|
|
|
|
code: args[1],
|
|
|
|
})).then((res) => {
|
|
|
|
const Embed = new MessageEmbed()
|
|
|
|
.setColor('#FFFF00')
|
|
|
|
.setTitle('Output')
|
|
|
|
.setDescription(`\`\`\`${res.data}\`\`\``);
|
|
|
|
channeldc.send({embeds: [Embed]});
|
|
|
|
}).catch((err) => {
|
|
|
|
throw err;
|
|
|
|
});
|
2022-11-07 08:08:29 -05:00
|
|
|
} else {
|
|
|
|
throw new SyntaxError('Invalid argument');
|
2022-10-14 04:46:41 -04:00
|
|
|
}
|
|
|
|
},
|
2022-08-14 05:51:45 -04:00
|
|
|
};
|