FNFBoyfriendBot v5.0.2 Build:315
This commit is contained in:
parent
2d80a02f15
commit
52ad936681
16 changed files with 283 additions and 121 deletions
47
bot.js
47
bot.js
|
@ -6,7 +6,7 @@ const util = require('node:util')
|
|||
console.log(`Starting ${process.env["buildstring"]} .......`)
|
||||
console.log(`Foundation: ${process.env["FoundationBuildString"]}`)
|
||||
console.log('this may take a few moments....')
|
||||
|
||||
require('events').EventEmitter.defaultMaxListeners = 20;
|
||||
function createBot(options = {}) {
|
||||
const bot = new EventEmitter()
|
||||
const rs = require('randomstring')
|
||||
|
@ -17,7 +17,7 @@ const rs = require('randomstring')
|
|||
options.hideErrors ??= false // HACK: Hide errors by default as a lazy fix to console being spammed with them
|
||||
options.console ??= true
|
||||
options.input ??= true
|
||||
|
||||
//options.logger ??= true
|
||||
// MainPrefix: "~",
|
||||
// SecondaryPrefix:'%',
|
||||
//TertiaryPrefix:'@'
|
||||
|
@ -77,36 +77,53 @@ options.input ??= true
|
|||
bot.buildstring = process.env['buildstring']
|
||||
bot.fbs = process.env['FoundationBuildString']
|
||||
bot.version = bot.options.version
|
||||
console.log(`Username: ${bot.username}`)
|
||||
console.log(`Username: ${bot.options.username}`)
|
||||
console.log(`Host: ${bot.options.host}:${bot.options.port}`)
|
||||
console.log(`Minecraft java version: ${bot.options.version}`)
|
||||
/* console.log(`Username: ${bot.username}`)
|
||||
console.log(`Host: ${bot.host}:${bot.port}`)
|
||||
console.log(`Minecraft java version: ${bot.version}`)
|
||||
console.log(`Minecraft java version: ${bot.version}`)*/
|
||||
})
|
||||
//bot.visibility = false
|
||||
//reason, fullReason
|
||||
client.on('end', reason => { bot.emit('end', reason)
|
||||
|
||||
//console.log(util.inspect(reason))
|
||||
|
||||
})
|
||||
client.on('disconnect', reason => {
|
||||
bot.emit('disconnect', reason)
|
||||
//console.log(reason)
|
||||
})
|
||||
|
||||
client.on('kick_disconnect', reason => {
|
||||
bot.emit('kick_disconnect', reason)
|
||||
console.log(reason)
|
||||
})
|
||||
client.on('keep_alive', ({ keepAliveId }) => {
|
||||
bot.emit('keep_alive', { keepAliveId })
|
||||
|
||||
})
|
||||
|
||||
client.on('error', error => bot.emit('error', error), )
|
||||
|
||||
//client.end(reason, fullReason)
|
||||
|
||||
})
|
||||
/*
|
||||
bot._client.on('kick_disconnect', (data) => {
|
||||
const parsed = JSON.parse(data.reason)
|
||||
bot.end(parsed, 'kick_disconnect')
|
||||
})
|
||||
|
||||
|
||||
*/
|
||||
const buildstring = process.env['buildstring']
|
||||
bot.end = (reason = 'end', event) => {
|
||||
bot.emit('end', reason, event)
|
||||
bot.removeAllListeners()
|
||||
bot._client.end()
|
||||
bot._client.removeAllListeners()
|
||||
}
|
||||
|
||||
const client = options.client ?? mc.createClient(options)
|
||||
bot._client = client
|
||||
bot.emit('init_client', client)
|
||||
|
||||
bot.bots = options.bots ?? [bot]
|
||||
bot.setMaxListeners(20)
|
||||
bot._client.setMaxListeners(20)
|
||||
//bot.setMaxListeners(Infinity)
|
||||
//bot._client.setMaxListeners(Infinity)
|
||||
|
||||
// Modules
|
||||
bot.loadModule = module => module(bot, options)
|
||||
|
|
52
chatqueue.js
52
chatqueue.js
|
@ -1,52 +0,0 @@
|
|||
function inject (bot, options) {
|
||||
bot.chatQueue = []
|
||||
bot._chatQueue = []
|
||||
|
||||
const _chatQueueInterval = setInterval(() => {
|
||||
if (bot.chatQueue.length !== 0) {
|
||||
if (containsIllegalCharacters(bot.chatQueue[0])) {
|
||||
bot.chatQueue.shift()
|
||||
return
|
||||
};
|
||||
|
||||
for (const subMessage of bot.chatQueue[0].split('\n')) {
|
||||
if (!subMessage) return
|
||||
let smallMsg
|
||||
for (let i = 0; i < subMessage.length; i += config.chat.messageLength) {
|
||||
smallMsg = subMessage.substring(i, i + config.chat.messageLength)
|
||||
bot._chatQueue.push(smallMsg)
|
||||
}
|
||||
}
|
||||
bot.chatQueue.shift()
|
||||
}
|
||||
}, 0)
|
||||
const chatQueueInterval = setInterval(function () {
|
||||
if (bot._chatQueue.length !== 0) {
|
||||
if (bot._chatQueue[0].startsWith('/') && minecraftVersionToNumber(bot.version) >= 1.20) {
|
||||
|
||||
} else {
|
||||
bot._client.chat(bot._chatQueue[0])
|
||||
}
|
||||
|
||||
bot._chatQueue.shift()
|
||||
}
|
||||
}, 450)
|
||||
bot.chat = (message) => {
|
||||
bot.chatQueue.push(String(message))
|
||||
}
|
||||
|
||||
bot.on('end', () => {
|
||||
clearInterval(chatQueueInterval)
|
||||
clearInterval(_chatQueueInterval)
|
||||
})
|
||||
|
||||
function listener (packet) {
|
||||
chatPacketListener(
|
||||
packet,
|
||||
bot,
|
||||
minecraftVersionToNumber(bot.version) >= 1.20
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = inject
|
|
@ -20,6 +20,13 @@ const bots = [
|
|||
|
||||
foundation: 'added botsrun for the funni along with making the bot be able to auto refill its core now and fill the core from a command block(edit: nevermind its very buggy reverting it back to how it originally filled its core) and adding a hover event to netmsg along with having the test command tellraw the players display name in the command and added support for 3 command prefixes',
|
||||
exclaimer:'12/23/23',
|
||||
},
|
||||
{//
|
||||
name: { text: 'v5.0.2', color: 'green', bold:false },
|
||||
authors: [''],
|
||||
|
||||
foundation: '12/26/23',
|
||||
exclaimer:'fixed the issue with the cpu checking in the info command added discord hashing back into the bot to work along side the keys made it check to see if the config file is in the directory and if not it will recreate the config from default.js',
|
||||
},
|
||||
]//
|
||||
//back
|
||||
|
|
|
@ -144,15 +144,15 @@ module.exports = {
|
|||
context.source.sendFeedback({ color: "gray", text: `OS platform: ${os.platform()}`})
|
||||
context.source.sendFeedback({ color: "gray", text: `OS name: ${os.version()}`})
|
||||
context.source.sendFeedback({ color: "gray", text: `CPU cores: ${os.cpus().length}`})
|
||||
/*if (os.platform() === 'win32')
|
||||
context.source.sendFeedback( { color: "gray", text: `CPU model: ${await getCpuModelName()}`})
|
||||
return*/
|
||||
/*const os = require('os') const cpus = os.cpus() for (const cpu of cpus){bot.tellraw(cpu.model)}*/
|
||||
//os.cpus()[0].model
|
||||
/*
|
||||
if (os.platform() !== 'linux'){
|
||||
source.sendFeedback({text:'cannot find the cpu model are you sure the bot is running on linux?', color:'red'})
|
||||
}
|
||||
else if (os.platform() === 'linux') {
|
||||
source.sendFeedback({ color: "gray", text: `CPU model: ${await getCpuModelName()}`})
|
||||
}
|
||||
*/ source.sendFeedback({ color: "gray", text: `CPU model: ${await os.cpus()[0].model}`})
|
||||
// }
|
||||
/*translate: '\n %s \n %s \n %s \n %s \n %s \n %s \n %s',//lazy fix
|
||||
with: [
|
||||
{ color: "gray", text: `Hostname: ${os.hostname()}`},
|
||||
|
|
|
@ -10,11 +10,14 @@ trustLevel: 1,
|
|||
const hash = bot.hash
|
||||
const args = context.arguments
|
||||
const ownerhash = bot.owner
|
||||
|
||||
const discordHash = bot.hashing.hash
|
||||
if (args[0] === hash) {
|
||||
source.sendFeedback({ text: 'Valid Hash', color: 'green' })
|
||||
} else if (args[0] === ownerhash) {
|
||||
}else if (args[0] === ownerhash) {
|
||||
source.sendFeedback({text: 'Valid OwnerHash', color:'green'})
|
||||
}
|
||||
else if (discordHash) {
|
||||
source.sendFeedback({ text: 'Valid Hash', color: 'green' })
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
79
default.js
Normal file
79
default.js
Normal file
|
@ -0,0 +1,79 @@
|
|||
|
||||
{
|
||||
module.exports = {
|
||||
|
||||
bots: [
|
||||
{
|
||||
host: "localhost",
|
||||
username:username(),
|
||||
version:"1.20.1",
|
||||
reconnectDelay: 6000,
|
||||
language:"lolus",
|
||||
console:true,
|
||||
input: true,
|
||||
commands: {
|
||||
MainPrefix: "set Main Prefix here",
|
||||
SecondaryPrefix:'set Secondary prefix here',
|
||||
TertiaryPrefix:'set Tertiary Prefix here'
|
||||
},
|
||||
Core: {
|
||||
customName:"core customName here",
|
||||
core: true,
|
||||
},
|
||||
discord: {
|
||||
channelId: "discord channelId here",
|
||||
invite: "discord invite link here",
|
||||
commandPrefix: "discord command prefix here"
|
||||
},
|
||||
skin: {
|
||||
torso:{
|
||||
jacket:true,
|
||||
cape:true,
|
||||
},
|
||||
arms: {
|
||||
leftSleeve:true,
|
||||
rightSleeve:true,
|
||||
},
|
||||
legs:{
|
||||
leftPants:true,
|
||||
rightPants:true,
|
||||
},
|
||||
head:{
|
||||
hat:true
|
||||
},
|
||||
},
|
||||
selfcare: {
|
||||
unmuted: true,
|
||||
vanished: true,
|
||||
prefix: true,
|
||||
skin: true,
|
||||
cspy: true,
|
||||
op: true,
|
||||
gmc: true,
|
||||
username:true,
|
||||
nickname: true,
|
||||
god:true,
|
||||
tptoggle: true,
|
||||
interval:500,
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function username() {
|
||||
const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; // remove sus characters like ` or like ( or whatever because it breaks whatever
|
||||
let username = '';
|
||||
for (let i = 0; i < 9; i++) {
|
||||
const randomIndex = Math.floor(Math.random() * characters.length);
|
||||
username += characters[randomIndex];
|
||||
}
|
||||
return username;
|
||||
}
|
||||
}
|
24
index.js
24
index.js
|
@ -2,7 +2,12 @@ const util = require('util')
|
|||
const createBot = require('./bot.js')
|
||||
//const chomensjs = require('./ChomensJS')
|
||||
// TODO: Load a default config
|
||||
const config = require('./config.js')
|
||||
const fs = require('fs/promises')
|
||||
const fileExist = require('./util/file-exists')
|
||||
const path = require('path')
|
||||
|
||||
function load () {
|
||||
//const config = require('./config.js')
|
||||
const readline = require('readline')
|
||||
|
||||
const rl = readline.createInterface({
|
||||
|
@ -19,12 +24,29 @@ const bots = []
|
|||
bot.console.useReadlineInterface(rl)
|
||||
|
||||
// bot.on('error', (error), util.inspect(error))
|
||||
|
||||
try{
|
||||
bot.on('error', console.error)
|
||||
}catch(error){
|
||||
console.log(error.stack)
|
||||
}
|
||||
}
|
||||
}
|
||||
async function checkConfig () {
|
||||
if (!await fileExist(path.join(__dirname, 'config.js'))) {
|
||||
console.error('Config not found! Creating a new Config from ')
|
||||
await fs.copyFile(path.join(__dirname, 'default.js'), path.join(__dirname, 'config.js'))
|
||||
} if (await fileExist(path.join(__dirname, 'config.js'))){
|
||||
console.log('Config found! loading config please wait,......')
|
||||
}
|
||||
|
||||
config = require('./config.js')
|
||||
load()
|
||||
}
|
||||
|
||||
checkConfig()
|
||||
|
||||
process.on('uncaughtException', (e) => {
|
||||
console.log('uncaught ' + e.stack)
|
||||
})
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ async function inject (bot, options) {
|
|||
bot.on('packet.login', (data) =>{
|
||||
const timer = setInterval(() => {
|
||||
bot.core.refill()
|
||||
}, 60000)
|
||||
}, 180000)
|
||||
bot.on('end', (bot) => {
|
||||
clearInterval(timer)
|
||||
})
|
||||
|
|
|
@ -33,14 +33,16 @@ const now = new Date().toLocaleString("en-US",{timeZone:"America/CHICAGO"})
|
|||
if(
|
||||
source?.sources?.discord &&
|
||||
command.trustLevel === 1 &&
|
||||
!roles?.some(role => role.name == 'trusted' || role.name == 'FNFBoyfriendBot Owner')
|
||||
!roles?.some(role => role?.name == 'trusted' || role?.name == 'FNFBoyfriendBot Owner') ? true : false
|
||||
) throw new CommandError({text:'You are not Trusted!', color:'red'})
|
||||
if (
|
||||
!source?.sources?.discord &&
|
||||
command.trustLevel === 1 &&
|
||||
args[0] !== bot.hash &&
|
||||
args[0] !== bot.owner
|
||||
args[0] !== bot.owner &&
|
||||
args[0] !== bot.hashing.hash
|
||||
) throw new CommandError({text:'Invalid Hash or Invalid Owner Hash', color:'red'})
|
||||
bot.hashing.updateHash()
|
||||
const now = new Date().toLocaleString("en-US",{timeZone:"America/CHICAGO"})
|
||||
const player = source?.player?.profile?.name
|
||||
const uuid = source?.player?.uuid
|
||||
|
@ -48,14 +50,18 @@ const now = new Date().toLocaleString("en-US",{timeZone:"America/CHICAGO"})
|
|||
const date = new Date().toLocaleDateString("en-US", {timeZone:"America/CHICAGO"})
|
||||
|
||||
bot.console.hash = function (error, source) {
|
||||
console.log(`<\x1b[0m\x1b[35m${time} \x1b[0m\x1b[96m${date}\x1b[0m> [${bot.options.host}:${bot.options.port}\x1b[0m] ` + `[\x1b[0m\x1b[92mHash\x1b[0m]: \x1b[0m\x1b[92mPlayer\x1b[0m: ${player}, \x1b[0m\x1b[92mUUID\x1b[0m:${uuid}, \x1b[0m\x1b[92mHash\x1b[0m:${bot.hash}\x1b[0m]` )
|
||||
console.log(`<\x1b[0m\x1b[35m${time} \x1b[0m\x1b[96m${date}\x1b[0m> [${bot.options.host}:${bot.options.port}\x1b[0m] ` + `[\x1b[0m\x1b[92mHash\x1b[0m]: \x1b[0m\x1b[92mPlayer\x1b[0m: ${player}, \x1b[0m\x1b[92mUUID\x1b[0m:${uuid}, \x1b[0m\x1b[92mHash\x1b[0m:${bot.hash || bot.hashing.hash}\x1b[0m]` )
|
||||
}
|
||||
bot.console.discordHash = function (error, source) {
|
||||
console.log(`<\x1b[0m\x1b[35m${time} \x1b[0m\x1b[96m${date}\x1b[0m> [${bot.options.host}:${bot.options.port}\x1b[0m] ` + `[\x1b[0m\x1b[92mHash\x1b[0m]: \x1b[0m\x1b[92mPlayer\x1b[0m: ${player}, \x1b[0m\x1b[92mUUID\x1b[0m:${uuid}, \x1b[0m\x1b[92mHash\x1b[0m:${bot.hashing.hash}\x1b[0m]` )
|
||||
}
|
||||
bot.console.ownerHash = function (error, source) {
|
||||
console.log(`<\x1b[0m\x1b[35m${time} \x1b[0m\x1b[96m${date}\x1b[0m> [${bot.options.host}:${bot.options.port}\x1b[0m] ` + `[\x1b[0m\x1b[31mOwnerHash\x1b[0m]: \x1b[0m\x1b[92mPlayer\x1b[0m: ${player}, \x1b[0m\x1b[92mUUID\x1b[0m:${uuid}, \x1b[0m\x1b[31mOwnerHash\x1b[0m:${bot.owner}\x1b[0m]` )
|
||||
}
|
||||
if (args[0] === bot.hash) {
|
||||
bot.console.hash()
|
||||
} else if (args[0] === bot.owner) {
|
||||
}
|
||||
else if (args[0] === bot.owner) {
|
||||
bot.console.ownerHash()
|
||||
}
|
||||
if (
|
||||
|
@ -81,16 +87,8 @@ bot.console.ownerHash = function (error, source) {
|
|||
//command.hashOnly && command.ownerOnly && args.length !== 0 && source.hash && source.owner
|
||||
// if (command.hashOnly && args.length === 0) throw new CommandError({ translate: 'Please provide a hash or a OwnerHash', color: 'red' })
|
||||
|
||||
const now = new Date().toLocaleString("en-US",{timeZone:"America/CHICAGO"})
|
||||
|
||||
const time = new Date().toLocaleTimeString("en-US", {timeZone:"America/CHICAGO"})
|
||||
const date = new Date().toLocaleDateString("en-US", {timeZone:"America/CHICAGO"})
|
||||
|
||||
bot.console.hash = function (error, source) {
|
||||
console.log()
|
||||
}//<\x1b[0m\x1b[35m${time} \x1b[0m\x1b[96m${date}\x1b[0m> [${bot.options.host}:${bot.options.port}\x1b[0m] ` + `[\x1b[0m\x1b[92mHash\x1b[0m]: \x1b[0m\x1b[92mPlayer\x1b[0m: ${player}, \x1b[0m\x1b[92mUUID\x1b[0m:${uuid}, \x1b[0m\x1b[92mHash\x1b[0m:${bot.hash}\x1b[0m]`
|
||||
bot.console.ownerHash = function (error, source) {
|
||||
console.log(`` )// actual hash
|
||||
//<\x1b[0m\x1b[35m${time} \x1b[0m\x1b[96m${date}\x1b[0m> [${bot.options.host}:${bot.options.port}\x1b[0m] ` + `[\x1b[0m\x1b[92mHash\x1b[0m]: \x1b[0m\x1b[92mPlayer\x1b[0m: ${player}, \x1b[0m\x1b[92mUUID\x1b[0m:${uuid}, \x1b[0m\x1b[92mHash\x1b[0m:${bot.hash}\x1b[0m]`
|
||||
// actual hash
|
||||
//but look in hashing.js
|
||||
//im looking through chomensjs's command handler for reference
|
||||
//💀
|
||||
|
@ -151,7 +149,7 @@ if (command.trustLevel > 0) {
|
|||
//ik that but why tf is it erroring
|
||||
|
||||
// wat the fard
|
||||
} // sus
|
||||
// sus
|
||||
|
||||
return command.execute({ bot, source, arguments: args })
|
||||
} catch (error) {
|
||||
|
@ -207,19 +205,10 @@ for (const filename of fs.readdirSync(path.join(__dirname, '../commands'))) {
|
|||
} catch (error) {
|
||||
console.error('Failed to load command', filename, ':', error)
|
||||
}
|
||||
bot.commandManager.reload
|
||||
const amongerus = Object.keys(require.cache).filter(r => r.startsWith(path.resolve(`../commands`)));
|
||||
bot.commandManager.fileReload = amongerus.forEach(f => { // I guess too mabe forEach
|
||||
console.log(`Unloaded: ${f}`);
|
||||
delete require.cache[f];
|
||||
|
||||
bot.commandManager.register(command)
|
||||
})
|
||||
|
||||
|
||||
if (process.env['anti-skid'] !== 'amogus is sus') {
|
||||
process.exit(0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = inject
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
const CommandSource = require('../CommandModules/command_source')
|
||||
//const log = require('../logger')
|
||||
//const logger = require('../util/logger')
|
||||
|
||||
function inject (bot, options, context, source) {
|
||||
|
||||
|
@ -175,15 +175,17 @@ const date = new Date().toLocaleDateString("en-US", {timeZone:"America/CHICAGO"}
|
|||
|
||||
const now = new Date().toLocaleString("en-US",{timeZone:"America/CHICAGO"})
|
||||
// const logtag = (JSON.stringify({"text":"[LOGS]", "color":"#00FF00"}))
|
||||
|
||||
|
||||
const time2 = new Date().toLocaleTimeString("en-US", {timeZone:"America/CHICAGO"})
|
||||
const date2 = new Date().toLocaleDateString("en-US", {timeZone:"America/CHICAGO"})
|
||||
|
||||
//const prefix = `<${time2} ${date2}> [${bot.options.host}:${bot.options.port}] `
|
||||
if (!bot.options.input) return
|
||||
if (!bot.options.console) return
|
||||
bot.console.logs(`${ansi}`)
|
||||
|
||||
|
||||
})
|
||||
}
|
||||
}
|
||||
}//const prefix = `<\x1b[0m\x1b[35m${time} \x1b[0m\x1b[96m${date}\x1b[0m> [${bot.options.host}:${bot.options.port}\x1b[0m] `
|
||||
}
|
||||
module.exports = inject
|
||||
/*const message = `[${moment().format('DD/MM/YY HH:mm:ss')} ${prefix}§r] [${bot.server.host}] `
|
||||
|
|
|
@ -24,7 +24,10 @@ function inject (bot, options) {
|
|||
}
|
||||
|
||||
client.on('ready', (context) => {
|
||||
bot.discord.channel = client.channels.cache.get(options.discord.channelId)
|
||||
//setMaxListeners(Infinity)
|
||||
client.setMaxListeners(25)
|
||||
|
||||
bot.discord.channel = client.channels.cache.get(options.discord.channelId)
|
||||
bot.discord.channel.send(`\`\`\`\nStarting ${process.env["buildstring"]}......\n\`\`\``)
|
||||
bot.discord.channel.send(`\`\`\`\nFoundation: ${process.env["FoundationBuildString"]}\n\`\`\``)
|
||||
bot.discord.channel.send(`\`\`\`\nSuccessfully logged into discord as ${bot.discord.client.user.username}#${bot.discord.client.user.discriminator}\n\`\`\``)
|
||||
|
|
|
@ -15,15 +15,19 @@ function inject(bot) {
|
|||
owner = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + ownerkey).digest('hex').substring(0, 16)
|
||||
bot.hash = hash
|
||||
bot.owner = owner
|
||||
|
||||
}, 2000)
|
||||
|
||||
function update() {
|
||||
hash = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + trustedkey).digest('hex').substring(0, 16)
|
||||
owner = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + ownerkey).digest('hex').substring(0, 16)
|
||||
bot.hash = hash
|
||||
bot.owner = owner
|
||||
}
|
||||
|
||||
//this should work right?
|
||||
|
||||
/*
|
||||
bot.discord.channel = client.channels.cache.get(options.discord.channelId)
|
||||
*/
|
||||
// ok
|
||||
/*
|
||||
bot.on('end', () => {
|
||||
|
@ -31,13 +35,77 @@ function inject(bot) {
|
|||
})
|
||||
*/
|
||||
}
|
||||
|
||||
let _hash = generateHash()
|
||||
const now = new Date().toLocaleString("en-US",{timeZone:"America/CHICAGO"})
|
||||
const time = new Date().toLocaleTimeString("en-US", {timeZone:"America/CHICAGO"})
|
||||
const date = new Date().toLocaleDateString("en-US", {timeZone:"America/CHICAGO"})
|
||||
|
||||
//bot.hashing = ''
|
||||
bot.hashing = {
|
||||
_hash: crypto.randomBytes(4).toString('hex').substring(0,16),
|
||||
//const key = process.env['FNFBoyfriendBotX_key']
|
||||
get hash () { return this._hash },
|
||||
set hash (value) {
|
||||
this._hash = value
|
||||
this.discordChannel?.send('```ansi\nTime: ' + time + ' ' + date + ' ' + '```' + '```ansi\n Hash for server ' + `${bot.options.host}:${bot.options.port}: ` + bot.hashing.hash + '\n```')
|
||||
},
|
||||
//`Hash for server ${bot.options.host}:${bot.options.port}: ${value}`
|
||||
generateHash () {
|
||||
return crypto.randomBytes(4).toString('hex').substring(0, 16)
|
||||
},
|
||||
|
||||
updateHash () {
|
||||
this.hash = this.generateHash()
|
||||
}
|
||||
}
|
||||
|
||||
bot.discord.client?.on('ready', () => {
|
||||
//bot.discord.client?.setMaxListeners(25)
|
||||
bot.hashing.discordChannel = bot.discord.client.channels.cache.get('1188677777336057987')
|
||||
//bot.hashing.discordChannel?.send()
|
||||
bot.hashing.discordChannel?.send('```ansi\nTime: ' + time + ' ' + date + ' ' + '```' + '```ansi\n Hash for server ' + `${bot.options.host}:${bot.options.port}: ` + bot.hashing.hash + '\n```')
|
||||
})// + bot.hashing.hash
|
||||
}//`Hash for server ${bot.options.host}:${bot.options.port}: ${value}`
|
||||
//nvm what?
|
||||
function generateHash () {
|
||||
return crypto.randomBytes(4).toString('hex')
|
||||
}
|
||||
module.exports = inject
|
||||
/* const interval = setInterval(() => {
|
||||
const normalKey = process.env['chomensjs_key']
|
||||
const ownerHashKey = process.env['chomensjs_owner_key']
|
||||
bot.hash = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + normalKey).digest('hex').substring(0, 16)
|
||||
bot.ownerHash = crypto.createHash('sha256').update(Math.floor(Date.now() / 10000) + ownerHashKey).digest('hex').substring(0, 16)
|
||||
}, 2000)
|
||||
bot.on('end', () => {
|
||||
clearInterval(interval)
|
||||
|
||||
|
||||
|
||||
|
||||
/* const crypto = require('crypto')
|
||||
|
||||
let _hash = generateHash()
|
||||
|
||||
function inject (bot) {
|
||||
bot.hashing = {
|
||||
_hash: crypto.randomBytes(4).toString('hex').substring(0,16),
|
||||
//const key = process.env['FNFBoyfriendBotX_key']
|
||||
get hash () { return this._hash },
|
||||
set hash (value) {
|
||||
this._hash = value
|
||||
this.discordChannel?.send('```ansi\n Hash for server ' + `${bot.options.host}:${bot.options.port}: ${value}` + '\n```')
|
||||
},
|
||||
//`Hash for server ${bot.options.host}:${bot.options.port}: ${value}`
|
||||
generateHash () {
|
||||
return crypto.randomBytes(4).toString('hex').substring(0, 16)
|
||||
},
|
||||
|
||||
updateHash () {
|
||||
this.hash = this.generateHash()
|
||||
}
|
||||
}
|
||||
|
||||
bot.discord.client?.on('ready', () => {
|
||||
bot.hashing.discordChannel = bot.discord.client.channels.cache.get('1120122720001208390')
|
||||
bot.hashing.discordChannel?.send('```ansi\n Hash for server ' + `${bot.options.host}:${bot.options.port}: ` + bot.hashing.hash + '\n```')
|
||||
})// + bot.hashing.hash
|
||||
}//`Hash for server ${bot.options.host}:${bot.options.port}: ${value}`
|
||||
//nvm what?
|
||||
function generateHash () {
|
||||
return crypto.randomBytes(4).toString('hex')
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -140,7 +140,7 @@ function inject (bot) {
|
|||
noteIndex = 0
|
||||
bot.core.run(`minecraft:bossbar remove ${bossbarName}`) // maybe not a good place to put it here but idk
|
||||
}
|
||||
if (process.env["buildstring"] !== "§5FridayNightFunkin§bBoyfriend§4Bot §8v5.0.1 §8Build:310")
|
||||
if (process.env["buildstring"] !== "§5FridayNightFunkin§bBoyfriend§4Bot §8v5.0.2 §8Build:315")
|
||||
{
|
||||
process.exit(1)
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ function inject (bot) {
|
|||
target.removePlayer = entry.removePlayer
|
||||
}
|
||||
}//
|
||||
if (process.env['FoundationBuildString'] !== 'Ultimate Foundation v2.0.1 Build:210')
|
||||
if (process.env['FoundationBuildString'] !== 'Ultimate Foundation v2.0.2 Build:215')
|
||||
{
|
||||
process.exit(1)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ const mc = require('minecraft-protocol')
|
|||
function reconnect (bot, options) {
|
||||
bot.reconnectDelay = options.reconnectDelay ?? 5200 // Set from 1000 to 5200 - yfd
|
||||
|
||||
bot.on('end', () => {
|
||||
bot.on('end', (reason) => {
|
||||
if (bot.reconnectDelay < 0) return
|
||||
|
||||
setTimeout(() => {
|
||||
|
@ -11,7 +11,7 @@ function reconnect (bot, options) {
|
|||
const client = options.client ?? mc.createClient(options)
|
||||
bot._client = client
|
||||
bot.emit('init_client', client)
|
||||
|
||||
|
||||
}, bot.reconnectDelay)
|
||||
})
|
||||
}
|
||||
|
|
24
util/logger.js
Normal file
24
util/logger.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const currentDate = new Date();
|
||||
const timestamp = `${currentDate.getFullYear()}-${(currentDate.getMonth() + 1).toString().padStart(2, '0')}-${currentDate.getDate().toString().padStart(2, '0')}`;
|
||||
const logFolder = path.join(__dirname, 'logs');
|
||||
const logFileName = `${timestamp}.log`;
|
||||
const logFilePath = path.join(logFolder, logFileName);
|
||||
const logStream = fs.createWriteStream(logFilePath, { flags: 'a' });
|
||||
|
||||
function log (message, toFile = true, toConsole = true) {
|
||||
const now = new Date().toLocaleString();
|
||||
|
||||
const toWrite = `[${now}] ${message}`
|
||||
|
||||
if (toFile) logStream.write(toWrite + '\n');
|
||||
if (toConsole) console.log(toWrite);
|
||||
};
|
||||
|
||||
if (!fs.existsSync(logFolder)) {
|
||||
fs.mkdirSync(logFolder);
|
||||
}
|
||||
//ohio
|
||||
module.exports = log
|
Loading…
Reference in a new issue