2022-12-24 00:59:52 -05:00
|
|
|
const { EmbedBuilder } = require('discord.js')
|
2022-11-27 02:35:28 -05:00
|
|
|
const { VM } = require('vm2')
|
|
|
|
const axios = require('axios')
|
|
|
|
const util = require('util')
|
|
|
|
const { stylize } = require('../util/colors/minecraft')
|
2022-08-14 05:51:45 -04:00
|
|
|
module.exports = {
|
|
|
|
name: 'eval',
|
|
|
|
alias: [],
|
|
|
|
description: 'Safe eval 100% secure!!!',
|
|
|
|
trusted: 0,
|
2022-11-13 02:41:59 -05:00
|
|
|
usage: [
|
2022-12-12 06:37:29 -05:00
|
|
|
'run <code>',
|
|
|
|
'reset',
|
|
|
|
'server (eval server) <code>'
|
2022-11-13 02:41:59 -05:00
|
|
|
],
|
2023-01-01 09:11:49 -05:00
|
|
|
async execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
2022-11-07 07:26:38 -05:00
|
|
|
if (args[0] === 'run') {
|
2022-08-14 05:51:45 -04:00
|
|
|
try {
|
2022-12-30 03:05:48 -05:00
|
|
|
bot.tellraw(selector, { text: util.inspect(bot.vm.run(args.slice(1).join(' ')), { stylize }).substring(0, 32000) })
|
2022-08-14 05:51:45 -04:00
|
|
|
} catch (err) {
|
2022-12-30 03:05:48 -05:00
|
|
|
bot.tellraw(selector, { 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-11-27 02:35:28 -05:00
|
|
|
bot.vm = new VM(bot.vmoptions)
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
2022-11-07 07:26:38 -05:00
|
|
|
if (args[0] === 'server') {
|
2023-01-01 09:11:49 -05:00
|
|
|
const res = await axios.post(config.eval.serverUrl, new URLSearchParams({
|
|
|
|
html: false,
|
|
|
|
showErrorMsg: false,
|
|
|
|
colors: 'minecraft',
|
|
|
|
code: args.slice(1).join(' ')
|
|
|
|
}).toString())
|
|
|
|
bot.tellraw(selector, { text: res.data })
|
2022-08-14 05:51:45 -04:00
|
|
|
}
|
|
|
|
},
|
2023-01-01 09:11:49 -05:00
|
|
|
async discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
2022-11-07 07:26:38 -05:00
|
|
|
if (args[0] === 'run') {
|
2022-12-24 00:59:52 -05:00
|
|
|
const Embed = new EmbedBuilder()
|
2022-12-01 05:15:30 -05:00
|
|
|
.setColor(config.discord.embedsColors.normal)
|
2022-11-27 02:35:28 -05:00
|
|
|
.setTitle('Output')
|
|
|
|
.setDescription(`\`\`\`${util.inspect(bot.vm.run(args.slice(1).join(' '))).substring(0, 1950)}\`\`\``)
|
|
|
|
channeldc.send({ embeds: [Embed] })
|
2022-11-07 08:08:29 -05:00
|
|
|
} else if (args[0] === 'reset') {
|
2022-11-27 02:35:28 -05:00
|
|
|
bot.vm = new VM(bot.vmoptions)
|
2022-11-07 08:08:29 -05:00
|
|
|
} else if (args[0] === 'server') {
|
2023-01-01 09:11:49 -05:00
|
|
|
const res = await axios.post(config.eval.serverUrl, new URLSearchParams({
|
|
|
|
html: false,
|
|
|
|
showErrorMsg: false,
|
|
|
|
code: args.slice(1).join(' ')
|
|
|
|
}).toString())
|
|
|
|
const Embed = new EmbedBuilder()
|
|
|
|
.setColor(config.discord.embedsColors.normal)
|
|
|
|
.setTitle('Output')
|
|
|
|
.setDescription(`\`\`\`${res.data}\`\`\``)
|
|
|
|
channeldc.send({ embeds: [Embed] })
|
2022-11-07 08:08:29 -05:00
|
|
|
} else {
|
2022-11-27 02:35:28 -05:00
|
|
|
throw new SyntaxError('Invalid argument')
|
2022-10-14 04:46:41 -04:00
|
|
|
}
|
2022-11-27 02:35:28 -05:00
|
|
|
}
|
|
|
|
}
|