mirror of
https://github.com/ChomeNS/chomens-bot-mc.git
synced 2024-11-14 10:44:55 -05:00
6895a37104
i totally did not used the search icon thing in vscode
84 lines
2.7 KiB
JavaScript
84 lines
2.7 KiB
JavaScript
/* eslint-disable max-len */
|
|
const {MessageEmbed} = 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',
|
|
alias: [],
|
|
description: 'Safe eval 100% secure!!!',
|
|
trusted: 0,
|
|
usage: '<run|reset|server> <code>',
|
|
execute: function(bot, username, usernameraw, sender, prefix, args, config) {
|
|
if (args[0]==='run') {
|
|
try {
|
|
bot.tellraw('@a', {text: `${util.inspect(bot.vm.run(args.slice(1).join(' ')), {stylize: stylize})}`.substring(0, 1900)});
|
|
} catch (err) {
|
|
bot.tellraw('@a', {text: `${util.inspect(err).replaceAll('runner', 'chayapak1')}`, color: 'red'});
|
|
}
|
|
}
|
|
if (args[0]==='reset') {
|
|
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('@a', {text: `${res.data}`});
|
|
}).catch((err) => {
|
|
bot.tellraw('@a', {text: `${err}`, color: 'red'});
|
|
});
|
|
}
|
|
// if (args[0]==='dineval') {
|
|
// axios
|
|
// .get('https://eval.dinhero21.repl.co', {
|
|
// headers: {
|
|
// data: args[1],
|
|
// colors: 'minecraft',
|
|
// },
|
|
// }).then((res) => {
|
|
// bot.tellraw('@a', {text: `${res.data}`}));
|
|
// }).catch((e) => {
|
|
// bot.tellraw('@a', {text: `${e}`, color: 'red'});
|
|
// });
|
|
// }
|
|
},
|
|
discordExecute: function(bot, username, usernameraw, sender, prefix, args, channeldc, message, config) {
|
|
if (args[0]==='run') {
|
|
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;
|
|
}
|
|
}
|
|
if (args[0]==='reset') {
|
|
bot.vm = new VM(bot.vmoptions);
|
|
}
|
|
if (args[0]==='server') {
|
|
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;
|
|
});
|
|
}
|
|
},
|
|
};
|