chomens-bot-js/plugins/vm.js

48 lines
1.2 KiB
JavaScript
Raw Normal View History

2023-01-10 05:07:25 -05:00
const mc = require('minecraft-protocol')
const crypto = require('crypto')
const colorConvert = require('color-convert')
const generateEaglerUsername = require('../util/generateEaglerUsername')
const uuid = require('uuid-by-string')
const moment = require('moment-timezone')
const cowsay = require('cowsay2')
const cows = require('cowsay2/cows')
const { VM } = require('vm2')
const randomstring = require('randomstring')
const mineflayer = require('mineflayer')
2023-02-11 23:43:55 -05:00
const Vec3 = require('vec3')
2023-01-10 05:07:25 -05:00
function inject (bot) {
const chatMessage = require('prismarine-chat')(bot.version)
const mcData = require('minecraft-data')(bot.version)
2023-02-05 06:35:11 -05:00
bot.vmOptions = {
2023-01-10 05:07:25 -05:00
timeout: 2000,
sandbox: {
run (cmd) {
bot.core.run(cmd)
},
mc,
mineflayer,
chat: bot.chat,
moment,
randomstring,
uuid,
chatMessage,
crypto,
colorConvert,
bruhifyText (message) {
if (
typeof message !== 'string'
) throw new SyntaxError('message must be a string')
bot.bruhifyText = message.substring(0, 1000)
},
generateEaglerUsername,
cowsay,
cows,
2023-02-11 23:43:55 -05:00
mcData,
Vec3
2023-01-10 05:07:25 -05:00
}
}
2023-02-05 06:35:11 -05:00
bot.vm = new VM(bot.vmOptions)
2023-01-10 05:07:25 -05:00
};
module.exports = { inject }