mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
eval server fix + improve(?)
real
This commit is contained in:
parent
59a6d573b8
commit
c4bd05bb96
1 changed files with 19 additions and 28 deletions
|
@ -2,7 +2,6 @@ const { EmbedBuilder } = require('discord.js')
|
|||
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',
|
||||
|
@ -14,7 +13,7 @@ module.exports = {
|
|||
'reset',
|
||||
'server (eval server) <code>'
|
||||
],
|
||||
execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
async execute (bot, username, sender, prefix, args, config, hash, ownerhash, selector) {
|
||||
if (args[0] === 'run') {
|
||||
try {
|
||||
bot.tellraw(selector, { text: util.inspect(bot.vm.run(args.slice(1).join(' ')), { stylize }).substring(0, 32000) })
|
||||
|
@ -26,20 +25,16 @@ module.exports = {
|
|||
bot.vm = new VM(bot.vmoptions)
|
||||
}
|
||||
if (args[0] === 'server') {
|
||||
axios
|
||||
.post(config.eval.serverUrl, querystring.stringify({
|
||||
html: false,
|
||||
showErrorMsg: false,
|
||||
colors: 'minecraft',
|
||||
code: args[1]
|
||||
})).then((res) => {
|
||||
bot.tellraw(selector, { text: res.data })
|
||||
}).catch((err) => {
|
||||
bot.tellraw(selector, { text: err, color: 'red' })
|
||||
})
|
||||
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 })
|
||||
}
|
||||
},
|
||||
discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
async discordExecute (bot, username, sender, prefix, args, channeldc, message, config) {
|
||||
if (args[0] === 'run') {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
|
@ -49,20 +44,16 @@ module.exports = {
|
|||
} else if (args[0] === 'reset') {
|
||||
bot.vm = new VM(bot.vmoptions)
|
||||
} else if (args[0] === 'server') {
|
||||
axios
|
||||
.post(config.eval.serverUrl, querystring.stringify({
|
||||
html: false,
|
||||
showErrorMsg: false,
|
||||
code: args[1]
|
||||
})).then((res) => {
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(config.discord.embedsColors.normal)
|
||||
.setTitle('Output')
|
||||
.setDescription(`\`\`\`${res.data}\`\`\``)
|
||||
channeldc.send({ embeds: [Embed] })
|
||||
}).catch((err) => {
|
||||
throw err
|
||||
})
|
||||
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] })
|
||||
} else {
|
||||
throw new SyntaxError('Invalid argument')
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue