2023-12-17 14:55:27 -05:00
|
|
|
const CommandError = require('../CommandModules/command_error')
|
|
|
|
module.exports = {
|
|
|
|
name: 'servereval',
|
|
|
|
description:['no'],
|
2023-12-20 11:54:03 -05:00
|
|
|
trustLevel: 2,
|
2023-12-17 14:55:27 -05:00
|
|
|
aliases:['svreval'],
|
2024-01-26 21:24:08 -05:00
|
|
|
async execute (context, arguments, selector) {
|
2023-12-17 14:55:27 -05:00
|
|
|
const bot = context.bot
|
|
|
|
// const args = context.arguments.join(' ')
|
|
|
|
const source = context.source
|
|
|
|
// throw new CommandError('temp disabled')
|
|
|
|
const { stylize } = require('../util/eval_colors')
|
|
|
|
const util = require('util')
|
|
|
|
const args = context.arguments
|
2024-01-26 21:24:08 -05:00
|
|
|
const ChatMessage = require('prismarine-chat')(bot.options.version)
|
2023-12-17 14:55:27 -05:00
|
|
|
const script = args.slice(1).join(' ');
|
2024-01-26 21:24:08 -05:00
|
|
|
//bot.chat(ChatMessage.fromNotch(message).toMotd().replaceAll('\xa7', '&'))
|
|
|
|
if (!args && !args[0] && !args[1] && !args[2] && !args[3] && !args[4] ) return
|
|
|
|
function sleep(ms) {
|
|
|
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
|
}//ChatMessage.fromNotch(await sleep(500) ).toMotd().replaceAll('§', '&')`
|
|
|
|
try {
|
|
|
|
if(source.sources.console){
|
|
|
|
bot.console.info({ text: util.inspect(eval(args.slice(0).join(' ')), { stylize }).substring(0, 32700) })
|
|
|
|
bot.console.info({ text: `Script input: ${script}` })
|
|
|
|
} else
|
2024-01-27 11:08:12 -05:00
|
|
|
if(!bot.options.Core.enabled && !source.sources.console){
|
2024-01-26 21:24:08 -05:00
|
|
|
|
|
|
|
bot.chat(ChatMessage.fromNotch(await sleep(500) ?? { text: util.inspect(eval( args.slice(1).join(' ')), { stylize }).substring(0, 32700) }).toMotd().replaceAll('§', '&'))
|
|
|
|
}else {
|
|
|
|
|
|
|
|
//{ text: util.inspect(eval(script), { stylize }).substring(0, 32700) }
|
2024-01-12 12:24:01 -05:00
|
|
|
source.sendFeedback({ text: util.inspect(eval(script), { stylize }).substring(0, 32700) })
|
|
|
|
source.sendFeedback({ text: `Script input: ${script}` })
|
2024-01-26 21:24:08 -05:00
|
|
|
}
|
|
|
|
} catch (err) {
|
2024-01-27 11:08:12 -05:00
|
|
|
if(!bot.options.Core.enabled && !source.sources.console){
|
2024-01-26 21:24:08 -05:00
|
|
|
bot.chat(`&4${err.message}`)
|
|
|
|
}else if(source.sources.console){
|
|
|
|
bot.console.warn({ text: err.message, color: 'red' })
|
|
|
|
} else {
|
|
|
|
source.sendFeedback({ text: err.message, color: 'red' })
|
2024-01-12 12:24:01 -05:00
|
|
|
source.sendFeedback({ text: `Script input: ${script}` })
|
2023-12-17 14:55:27 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-01-26 21:24:08 -05:00
|
|
|
}
|
2023-12-17 14:55:27 -05:00
|
|
|
|
|
|
|
|
|
|
|
/* try {
|
|
|
|
bot.tellraw({ text: util.inspect(eval(context.arguments.slice().join(' ')), { stylize }).substring(0, 32700) })
|
|
|
|
} catch (err) {
|
|
|
|
bot.tellraw({ text: util.inspect(err).replaceAll('runner', 'runner'), color: 'red' })
|
|
|
|
}
|
|
|
|
*/
|