From d449ec6f201c8152460b5acf9143bd02259547fb Mon Sep 17 00:00:00 2001 From: ChomeNS Date: Tue, 10 Jan 2023 17:07:25 +0700 Subject: [PATCH] actually a very among us fix --- bot.js | 68 --------------------------------------------------- plugins/vm.js | 45 ++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 68 deletions(-) create mode 100644 plugins/vm.js diff --git a/bot.js b/bot.js index 0faa8db..266bcc3 100644 --- a/bot.js +++ b/bot.js @@ -1,19 +1,9 @@ - const mc = require('minecraft-protocol') -const crypto = require('crypto') -const colorConvert = require('color-convert') const sleep = require('sleep-promise') -const generateEaglerUsername = require('./util/generateEaglerUsername') const { EventEmitter } = require('events') const { loadPlugins } = require('./util/loadPlugins') -const uuid = require('uuid-by-string') -const moment = require('moment-timezone') -const cowsay = require('cowsay2') -const cows = require('cowsay2/cows') const util = require('node:util') -const { VM } = require('vm2') const randomstring = require('randomstring') -const mineflayer = require('mineflayer') /** * makes the bot @@ -59,9 +49,6 @@ async function createBot (server, config, getBots, setNewBot, dcclient, rl) { const channel = dcclient.channels.cache.get(config.discord.servers[bot.options.host]) - bot.console.info( - `Connecting to: ${bot.options.host}:${bot.options.port}` - ) channel.send( `Connecting to: \`${bot.options.host}:${bot.options.port}\`` ) @@ -70,64 +57,9 @@ async function createBot (server, config, getBots, setNewBot, dcclient, rl) { bot.uuid = bot._client.uuid bot.username = bot._client.username - const chatMessage = require('prismarine-chat')(bot.version) - const mcData = require('minecraft-data')(bot.version) - - bot.console.info( - `Successfully logged in to: ${bot.options.host}:${bot.options.port}` - ) channel.send( `Successfully logged in to: \`${bot.options.host}:${bot.options.port}\`` ) - - bot.vmoptions = { - 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, - mcData - } - } - bot.vm = new VM(bot.vmoptions) - - // await sleep(1400); - // bot.tellraw('@a', [ - // { - // text: 'ChomeNS Bot', - // color: 'yellow', - // }, - // { - // text: ' - ', - // color: 'dark_gray', - // }, - // { - // text: 'made by ', - // color: 'gray', - // }, - // { - // text: 'chayapak', - // color: 'gold', - // }, - // ]); }) await loadPlugins(bot, dcclient, config, rl) diff --git a/plugins/vm.js b/plugins/vm.js new file mode 100644 index 0000000..e6f2172 --- /dev/null +++ b/plugins/vm.js @@ -0,0 +1,45 @@ +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') +function inject (bot) { + const chatMessage = require('prismarine-chat')(bot.version) + const mcData = require('minecraft-data')(bot.version) + bot.vmoptions = { + 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, + mcData + } + } + bot.vm = new VM(bot.vmoptions) +}; + +module.exports = { inject }