actually a very among us fix

This commit is contained in:
ChomeNS 2023-01-10 17:07:25 +07:00
parent 692f83b77d
commit d449ec6f20
2 changed files with 45 additions and 68 deletions

68
bot.js
View file

@ -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)

45
plugins/vm.js Normal file
View file

@ -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 }