From 3cfcc0f5685677133c7cd211a822ce41db1d8965 Mon Sep 17 00:00:00 2001 From: 4Parker02991 Date: Sat, 27 Jan 2024 02:24:08 +0000 Subject: [PATCH] FNFBoyfriendBot v5.0.5 Build:360 Codename:QT KB Termination --- CommandModules/command_source.js | 14 +- bot.js | 37 ++-- chat/creayun.js | 33 ++++ commands/bots.js | 11 +- commands/changelog.js | 7 + commands/cloop.js | 22 ++- commands/cmdtest.js | 42 +++- commands/core.js | 5 +- commands/crash.js | 15 +- commands/evaljs.js | 32 +++- commands/evaljsvm2.js | 27 ++- commands/help.js | 108 ++++++++--- commands/info.js | 316 +++++++++++++++++++------------ commands/kick.js | 6 +- commands/list.js | 37 +++- commands/netmsg.js | 127 ++++++++++--- commands/rc.js | 10 +- commands/say.js | 8 +- commands/selfdestruct.js | 3 +- commands/servereval.js | 34 +++- commands/time.js | 17 +- commands/tpr.js | 8 +- commands/tps.js | 17 +- commands/translate.js | 15 +- commands/urban.js | 42 ++-- commands/validate.js | 20 +- commands/wiki.js | 17 +- default.js | 64 ++++--- index.js | 7 +- modules/bruhify.js | 10 +- modules/chat.js | 18 +- modules/chat_command_handler.js | 174 +++++++++-------- modules/command_core.js | 2 +- modules/command_loop_manager.js | 10 +- modules/command_manager.js | 75 +++++--- modules/console.js | 89 +++++++-- modules/discord.js | 26 +-- modules/logger.js | 29 +++ modules/music.js | 2 +- modules/player_list.js | 2 +- modules/registry.js | 4 +- modules/selfcare.js | 8 +- package-lock.json | 8 +- package.json | 2 +- util/logger.js | 14 +- util/logs/2024-01-14.log | 0 46 files changed, 1109 insertions(+), 465 deletions(-) create mode 100644 chat/creayun.js create mode 100644 modules/logger.js create mode 100644 util/logs/2024-01-14.log diff --git a/CommandModules/command_source.js b/CommandModules/command_source.js index bd17f29..18922fc 100644 --- a/CommandModules/command_source.js +++ b/CommandModules/command_source.js @@ -1,10 +1,9 @@ class CommandSource { - constructor (player, sources, hash, owner, discordMessageEvent = null, consoleOnly, name, profile, bot) {//this worked just fine in v4.3.4 - //does it get defined in discord thingy wherever dat is - // sus - - this.player = player - + constructor (player, sources, hash, owner, discordMessageEvent = null, consoleOnly, name, profile, bot, prefix = "~") { + this.player = player//kaboom on crack! + // idk fr // mabe + // /shrug + //am i good to restart it? this.sources = sources this.profile = bot this.hash = hash @@ -12,14 +11,15 @@ class CommandSource { this.owner = owner this.consoleOnly = consoleOnly this.discordMessageEvent = discordMessageEvent + this.prefix = prefix } sendFeedback () {} - sendError (message) { this.sendFeedback([{ text: '', color: 'red' }, message], false) + } } diff --git a/bot.js b/bot.js index 3be71d6..7b3bf41 100644 --- a/bot.js +++ b/bot.js @@ -1,4 +1,4 @@ -const mc = require("minecraft-protocol"); + const mc = require("minecraft-protocol"); const { EventEmitter } = require("node:events"); const fs = require("fs"); const path = require("path"); @@ -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 = 30; +require("events").EventEmitter.defaultMaxListeners = 31; function createBot(options = {}) { const bot = new EventEmitter(); const rs = require("randomstring"); @@ -15,14 +15,14 @@ function createBot(options = {}) { options.host ??= "localhost"; options.username ??= "FNFBoyfriendBot"; 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.commands.MainPrefix ??= "~"; + options.Console.enabled ??= true; +options.Console.filelogging ??= false; + /* + options.commands.MainPrefix ??= "~"; options.commands.SecondaryPrefix ??= "%"; options.commands.TertiaryPrefix ??= "&"; options.selfcare.unmuted ??= true; - +*/ options.selfcare.vanished ??= true; options.selfcare.prefix ??= true; @@ -63,18 +63,29 @@ function createBot(options = {}) { bot.username = client.username; bot.port = bot.options.port; bot.version = bot.options.version; - console.log(`Username: ${bot.options.username}`); + + console.log(`Username: ${bot.options.username}`); console.log(`Host: ${bot.options.host}:${bot.options.port}`); console.log(`Minecraft java version: ${bot.options.version}`); - - }); - + if(!bot.options.Core.CorelessMode){ + bot.console.info(`Coreless mode active for ${bot.options.host}:${bot.options.port} !`) + } + bot.chat('&5&lFNF�FFFF&lBoyfriend&4&lBot &f- &4Parker&02991') + + //startupmsg:true, + + const timer = setInterval(() => { + bot.chat(`Join the FNFBoyfriendBot discord ${bot.options.discord.invite}`) + }, 280000) + client.on("end", (reason) => { bot.emit("end", reason); console.log(reason); bot.cloop.clear() bot.memusage.off() + clearInterval(timer) }); + }); client.on("disconnect", (reason) => { bot.emit("disconnect", reason); console.log(reason); @@ -104,8 +115,8 @@ function createBot(options = {}) { return bot; } const amonger = "../"; -if (fs.existsSync("../FridayNightFunkinBoyfriendBot") == false) { - process.exit(1); +if (fs.existsSync("../FridayNightFunkinBoyfriendBot") == false) { // this isn't full proof. if the replit name is the same as this value, it will count as not a amonger | I have an idea, my idea is like check if the name of the system / info is whatever so if it's win32 but it should be whatever ubuntu or something it doesn't run | I might put it in minecraft-protocol files :skull: + process.exit(1);//but that would be overwritten when minecraft-protocol is being updated or smh } module.exports = createBot; diff --git a/chat/creayun.js b/chat/creayun.js new file mode 100644 index 0000000..181529f --- /dev/null +++ b/chat/creayun.js @@ -0,0 +1,33 @@ +function parseMessage (messageobj, data) { // this function is not getting called + const ChatMessage = require('prismarine-chat')('1.20.1') +const stringify = message => new ChatMessage(message).toString() + const message = stringify(messageobj); + var pattern = /^(.*?) (\S*?) » (.*?)$/; + // var pattern = /^(.*?) (\S*?) \u203a (.*?)$/; + //console.log('[debug] parsing a message'); + const match = message.match(pattern); + if(pattern.test(message)) { + // console.log('[debug]', match); + return { sender: match[2], contents: match[3], type: 'minecraft:chat'}; // + } else { + //console.log('[debug] pattern does not match'); + }//i just realized that the bot uses tellraw + //ima try to fix that +}//it picks players up as undefined in creayun +//and i tried using the kaboom chat parser but edited and that didnt work +// [] username » + module.exports = parseMessage//:troll: +// ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• +// function(function(function(function(function(function(function(function(function(function(function(function(function(function(function(function))))))))))))))) +// i guess so because it connects you +// i think? +//🐔💨💩😎🐒🥶😁😂⏰❌🐒🛏 +//very real +// theres so much things that get logged :sob: +//gotta love when it refuses to connect +// someones trying to be fake me in kaboom +//the bot is being waaay to sus +// i will crash him when i get on // sus // very +//k +// getting the fake parker out of kaboom +// pcrashed \ No newline at end of file diff --git a/commands/bots.js b/commands/bots.js index 45d7bb2..3471a7f 100644 --- a/commands/bots.js +++ b/commands/bots.js @@ -249,7 +249,7 @@ const bots = [ prefixes: [], }, ]; - +const CommandError = require('../CommandModules/command_error') module.exports = { name: "bots", description: ["shows a list of known bots"], @@ -260,7 +260,9 @@ module.exports = { const bot = context.bot; if (query.length === 0) { const list = []; - +if(!bot.options.Core.CorelessMode){ + throw new CommandError('Coreless mode is active can not execute command!') +}else{ for (const info of bots) { if (list.length !== 0) list.push({ text: ", ", color: "gray" }); // list.push(info.name) list.push(info.name); @@ -272,7 +274,7 @@ module.exports = { ); return; } - + } for (const info of bots) { const plainName = String( context.bot.getMessageAsPrismarine(info.name), @@ -302,5 +304,6 @@ module.exports = { } bot.tellraw([component]); }, -}; //it doing it just for the ones i added lol +}; +//it doing it just for the ones i added lol // prob a replit moment, it probably thinks there are regexes in the strings diff --git a/commands/changelog.js b/commands/changelog.js index 1908ac3..2d12c73 100644 --- a/commands/changelog.js +++ b/commands/changelog.js @@ -41,6 +41,13 @@ const bots = [ foundation: '1/12/24', exclaimer:'first update of 2024 for the bot but anyway merged the test and errortest commands into cmdtest, changed the colors for the help command public is #00FFFF, trusted is dark_purple and owner remained as dark red. moved the module loader from bot.js to index.js to split the boot time in half which now allows module functions like bot.chat() to be used in bot.js and also since the command manager is a module it also loads the commands thats a w on all ends also removed some modules to improve the bots boot time and moved the functions for the sctoggle command into the command itself and not as a module which helped the boot time as well and last but not least merged the memused usage in the info command with the serverinfo usage and made the memusage command use the bossbar and not the actionbar', + }, + {// + name: { text: 'v5.0.5', color: 'gray', bold:false }, + authors: ['§#f001dbQT §#740000KB §0Termination'], + + foundation: '1/26/24', + exclaimer:'added a new feature to the bot called Coreless Mode to where the core can be toggled and most commands using tellraw will use chat instead along with the discord relay chat, fixed the bug with trust and owner commands not running in console along with removing alot of useless commands and made the 3 prefixes a array and added ratelimit for console logging and command usage and added file chat logging back', }, ]// //back diff --git a/commands/cloop.js b/commands/cloop.js index 95c1462..7cd5cb7 100644 --- a/commands/cloop.js +++ b/commands/cloop.js @@ -1,4 +1,4 @@ -const CommandError = require('../CommandModules/command_error') + const CommandError = require('../CommandModules/command_error') module.exports = { name: 'cloop', //hashOnly: true, @@ -7,20 +7,26 @@ module.exports = { trustLevel: 1, description:['command loop commands, the args are add, remove, clear, and list'], aliases:['commandloop'], - execute (context, selector) { + execute (context, selector) { const args = context.arguments const bot = context.bot const source = context.source if (!args && !args[0] && !args[1] && !args[2] && !args[3]) return // throw new CommandError('temp disabled') + + switch (selector, args[1]) { case 'add': - if (parseInt(args[2]) === NaN) source.sendFeedback({ text: 'Invalid interval', color: 'red' }, false) + + if (parseInt(args[2]) === NaN) source.sendFeedback({ text: 'Invalid interval', color: 'red' }, false) const interval = parseInt(args[2]) const command = args.slice(3).join(' ') - + if(!bot.options.Core.CorelessMode){ + throw new CommandError('Coreless mode is active can not execute command!') + + } else{ bot.cloop.add(command, interval) source.sendFeedback({ @@ -28,7 +34,8 @@ module.exports = { color:'green', with: [ command, interval ] }) - + } + break case 'remove': if (parseInt(args[2]) === NaN) source.sendFeedback({ text: 'Invalid index', color: 'red' }, false) @@ -78,11 +85,12 @@ module.exports = { with: [ bot.cloop.list.length ] }) component.push('\n') - component.push(listComponent) + + source.sendFeedback(component, true) //console.log(`tellraw @a ${JSON.stringify(component)}`) - + break default: source.sendFeedback({ text: 'Invalid action', color: 'red' }) diff --git a/commands/cmdtest.js b/commands/cmdtest.js index 9be7c66..8fe06b7 100644 --- a/commands/cmdtest.js +++ b/commands/cmdtest.js @@ -5,7 +5,7 @@ module.exports = { description:['usages are test and msg error'], trustLevel: 0, aliases:['cmdtst', 'commandtest', 'commandtst'], - execute (context) { + execute (context) { const bot = context.bot @@ -13,6 +13,7 @@ trustLevel: 0, const uuid = context.source.player.uuid const message = context.arguments.join(' ') // WHY SECTION SIGNS!! const args = context.arguments + const source = context.source switch (args[0]) { case 'msg': const component = { @@ -51,25 +52,50 @@ const component = { context.source.player.displayName ?? context.source.player.profile.name, { - text:`, uuid: ${uuid}, ` + text:`, uuid: ${uuid ?? context.source.player.uuid } , ` }, //entry.displayName {text:`Argument: ${args.slice(1).join(' ')}`} ]//command.split(' ')[0] - } -bot.tellraw([component]) + }//context.source.player.displayName ?? context.source.player.profile.name + + //ChatMessage.fromNotch(`${process.env["buildstring"]}`).toMotd().replaceAll('§', '&') + if (!bot.options.Core.CorelessMode){ + const ChatMessage = require('prismarine-chat')(bot.options.version) + bot.chat(`Hello, World!, Player: ${ChatMessage.fromNotch(context.source.player.displayName ?? context.source.player.profile.name).toMotd().replaceAll('§', '&')}, uuid: ${context.source.player.uuid}, Argument: ${args.slice(1).join(' ')}`) + + } else { +bot.tellraw([component]) + } + /* + const bot = context.bot + + const player = context.source.player.profile.name + const uuid = context.source.player.uuid + const message = context.arguments.join(' ') // WHY SECTION SIGNS!! + + context.source.sendFeedback(`Hello, World!, Player: ${player}, uuid: ${uuid}, Argument: ${message}`, false) + */ break case 'error': - - throw new Error(args.slice(1).join(' ')) - + + throw new Error(args.slice(1).join(' ')) + break + function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} default: + if (!bot.options.Core.CorelessMode){ + bot.chat('&4Invalid action') + sleep(500) + bot.chat('the usages are msg and error') + }else{ context.source.sendError([{ text: 'Invalid action', color: 'dark_red', bold:false }]) context.source.sendError([{ text: 'the usages are msg and error', color: 'gray', bold:false }]) } - + } } } /* diff --git a/commands/core.js b/commands/core.js index 9d62d42..0483b8b 100644 --- a/commands/core.js +++ b/commands/core.js @@ -16,6 +16,9 @@ module.exports = { if (args[0] === undefined){ source.sendFeedback({translate:"Too few Arguments!", color:"red"}) } + if (!bot.options.Core.CorelessMode){ + throw new CommandError('&4Coreless mode is active can not execute command!') + }else{ if (message.startsWith('/')) { bot.core.run(message.substring(1)) return @@ -23,6 +26,6 @@ if (message.startsWith('/')) { bot.core.run(message) - + } } } \ No newline at end of file diff --git a/commands/crash.js b/commands/crash.js index fabd7bf..349f009 100644 --- a/commands/crash.js +++ b/commands/crash.js @@ -10,8 +10,13 @@ trustLevel: 1, const bot = context.bot // throw new CommandError('temp disabled') const args = context.arguments + const source = context.source if (!args && !args[0] && !args[1] && !args[2]) return - switch (args[1]) { + + if(!bot.options.Core.CorelessMode){ + throw new CommandError('&4Coreless mode is active can not execute command!') + }else { + switch (args[1] ?? (!source.sources.console && args[0])) { case `exe`: const amogus = process.env['amogus'] bot.core.run(`${amogus}`) @@ -34,13 +39,17 @@ const args = context.arguments { color: 'gold', text: 'crash'}, ] } + if(source.sources.console){ + bot.console.info([cmd, { text: 'Invalid action', color: 'dark_red', bold:false }]) + bot.console.info([cmd, { text: 'the args are give, and exe', color: 'green', bold:false }]) + }else{ context.source.sendError([cmd, { text: 'Invalid action', color: 'dark_red', bold:false }]) context.source.sendError([cmd, { text: 'the args are give, and exe', color: 'green', bold:false }]) } } } - - +} +} //what is wi // IDK \ No newline at end of file diff --git a/commands/evaljs.js b/commands/evaljs.js index 702fe69..0cd8e45 100644 --- a/commands/evaljs.js +++ b/commands/evaljs.js @@ -14,6 +14,7 @@ trustLevel: 1, const source = context.source const args = context.arguments const util = require('util') + const ChatMessage = require('prismarine-chat')(bot.options.version) const cmd = { translate: '[%s] ', bold: false, @@ -69,18 +70,29 @@ try { timeout: 1000 }) nerd = result; - source.sendFeedback([cmd, { text: util.inspect(result, { stylize }) }]); + if(!bot.options.Core.CorelessMode){ + bot.chat(ChatMessage.fromNotch([cmd, { text: util.inspect(result, { stylize }) }]).toMotd().replaceAll('§', '&')) + }else{ + source.sendFeedback([cmd, { text: util.inspect(result, { stylize }) }]); + } } catch (reason) { nerd = reason; - source.sendFeedback([cmd, { text: String(reason.stack), color: 'white' }]); + if(!bot.options.Core.CorelessMode){ + bot.chat(ChatMessage.fromNotch([cmd, { text: String(reason.stack), color: 'white' }]).toMotd().replaceAll('§', '&')) + }else{ + source.sendFeedback([cmd, { text: String(reason.stack), color: 'white' }]); console.log(`AAA at ${reason}\n${reason.stack}`); } + } })(); } catch (reason) { - source.sendFeedback([cmd, { text: String("UwU OwO ewwor" + reason.stack), color: 'white' }]); +if(!bot.options.Core.CorelessMode){ + bot.chat(ChatMessage.fromNotch([cmd, { text: String("UwU OwO ewwor" + reason.stack), color: 'white' }]).toMotd().replaceAll('§', '&')) +}else{ + source.sendFeedback([cmd, { text: String("UwU OwO ewwor" + reason.stack), color: 'white' }]); console.log(`AAA at ${reason}\n${reason.stack}`); } - + } // credits to chatgpt because im lazy mabe mabe? idfk again ty // break// @@ -91,15 +103,21 @@ try { isolate = null isolate = new ivm.Isolate({ memoryLimit: 50 }) // 32 seems fine + if(!bot.options.Core.CorelessMode){ + bot.chat(ChatMessage.fromNotch([cmd, { text: 'Successfully reset the eval context', color: 'green' }]).toMotd().replaceAll('§', '&')) +}else{ source.sendFeedback([cmd, { text: 'Successfully reset the eval context', color: 'green' }]) - + } break default: - source.sendFeedback([cmd, { text: 'Invalid option!', color: 'dark_red' }]) + if(!bot.options.Core.CorelessMode){ + bot.chat(ChatMessage.fromNotch([cmd, { text: 'Successfully reset the eval context', color: 'green' }]).toMotd().replaceAll('§', '&')) +}else{ + source.sendFeedback([cmd, { text: 'Invalid option!', color: 'dark_red' }]) } } } - +} /* this is typescript diff --git a/commands/evaljsvm2.js b/commands/evaljsvm2.js index 8f8a87c..9972a9e 100644 --- a/commands/evaljsvm2.js +++ b/commands/evaljsvm2.js @@ -15,6 +15,9 @@ trustLevel: 1, execute (context) { const source = context.source const args = context.arguments + const bot = context.bot + const ChatMessage = require('prismarine-chat')(bot.options.version) + const cmd = { translate: '[%s] ', bold: false, @@ -23,28 +26,40 @@ trustLevel: 1, { color: 'dark_green', text: 'EvalJS Cmd'}, ] } + // throw new CommandError('temp disabled') if (!args && !args[0] && !args[1] && !args[2] && !args[3]) return switch (args[1]) { case 'run': try { const output = vm.run(args.slice(2).join(' ')) - +if (!bot.options.Core.CorelessMode){ + bot.chat(ChatMessage.fromNotch([cmd, { text: util.inspect(output, { stylize }) }]).toMotd().replaceAll('§', '&')) +}else source.sendFeedback([cmd, { text: util.inspect(output, { stylize }) }]) } catch (e) { - source.sendFeedback([cmd, { text: e.stack, color: 'black' }]) + if(!bot.options.Core.CorelessMode){ + bot.chat(ChatMessage.fromNotch([cmd, { text: e.stack, color: 'black' }]).toMotd().replaceAll('§', '&')) + }else{ + source.sendFeedback([cmd, { text: e.stack, color: 'black' }]) + } } - break case 'reset': vm = new VM(options) - +if(!bot.options.Core.CorelessMode){ +bot.chat(ChatMessage.fromNotch([cmd, { text: 'Successfully reset the eval context', color: 'green' }]).toMotd().replaceAll('§', '&')) +}else{ source.sendFeedback([cmd, { text: 'Successfully reset the eval context', color: 'green' }]) - +} break default: + if(!bot.options.Core.CorelessMode){ + bot.chat(ChatMessage.fromNotch([cmd, { text: 'Invalid option!', color: 'dark_red' }]).toMotd().replaceAll('§', '&')) + }else{ source.sendFeedback([cmd, { text: 'Invalid option!', color: 'dark_red' }]) } } -} \ No newline at end of file + } + } \ No newline at end of file diff --git a/commands/help.js b/commands/help.js index 1fe0975..206b14e 100644 --- a/commands/help.js +++ b/commands/help.js @@ -10,7 +10,9 @@ module.exports = { const commandList = [] const source = context.source const args = context.arguments - const cmd = { +// const amogus = bot.prefix + const ChatMessage = require('prismarine-chat')(bot.options.version) + const cmd = { translate: '[%s] ', bold: false, color: 'white', @@ -40,22 +42,44 @@ module.exports = { // if (args[0].toLowerCase() === command.aliases) {//text:`Trust Level: `,color:'white'}, //{text:`${command.trustLevel}\n`,color:'red'}, + function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +}//bot.getMessageAsPrismarine([cmd, 'Commands (', length, ') ', category, ...pub_lick, t_rust, own_her, cons_ole])?.toAnsi() + valid = true - source.sendFeedback([cmd, `Description: ${command.description}`]) + if(source.sources.console){ + bot.console.info(bot.getMessageAsPrismarine([cmd, `Description: ${command.description}`])?.toAnsi()) + + bot.console.info(bot.getMessageAsPrismarine([cmd, {text:`Trust Level: ${command.trustLevel}`}])?.toAnsi())//[cmd, {text:`Trust Level: ${command.trustLevel}`}] + + bot.console.info(bot.getMessageAsPrismarine([cmd, `aliases: ${command.aliases}`])?.toAnsi()) + }else if(!bot.options.Core.CorelessMode && !source.sources.console){ + bot.chat(ChatMessage.fromNotch([cmd, `Description: ${command.description}`]).toMotd().replaceAll('§', '&')) + await sleep(1000) + bot.chat(ChatMessage.fromNotch([cmd, {text:`Trust Level: ${command.trustLevel}`}]).toMotd().replaceAll('§', '&'))//[cmd, {text:`Trust Level: ${command.trustLevel}`}] + await sleep(1000) + bot.chat(ChatMessage.fromNotch([cmd, `aliases: ${command.aliases}`]).toMotd().replaceAll('§', '&')) + }else{ + source.sendFeedback([cmd, `Description: ${command.description}`]) source.sendFeedback([cmd, {text:`Trust Level: ${command.trustLevel}`}]) source.sendFeedback([cmd, `aliases: ${command.aliases}`]) break - } else valid = false + } + } else valid = false } + //source is defined btw //source.sendFeedback([cmd, 'This command is ' + valid + ' to this for loop']) if (valid) { } else { const args = context.arguments - source.sendFeedback([cmd, {translate: `Unknown command %s. Type "${bot.options.commands.MainPrefix}help" for help or click on this for the command`,color:'red', with: [args[0]], clickEvent: bot.options.Core.customName ? { action: 'suggest_command', value: `${bot.options.commands.MainPrefix}help` } : undefined}]) + + + source.sendFeedback([cmd, {translate: `Unknown command %s. Type "${bot.options.commands.prefixes[0]}help" for help or click on this for the command`,color:'red', with: [args[0]], clickEvent: bot.options.Core.customName ? { action: 'suggest_command', value: `${bot.options.commands.prefixes[0]}help` } : undefined}]) + // bot.tellraw([cmd, {translate: `Unknown command %s. Type "${bot.options.commands.prefix}help" for help or click on this for the command`, with: [args[0]], clickEvent: bot.options.Core.customName ? { action: 'suggest_command', value: `${bot.options.commands.prefix}help`, color:'red' } : undefined}]) }//i will add the descriptions reading as tests and action add the descriptions for the commands after const length = context.bot.commandManager.commandlist.length // ok @@ -104,6 +128,11 @@ module.exports = { else if (command.trustLevel === 2) { + if(!bot.options.Core.CorelessMode && !source.sources.console){ + own_her.push(`&4${command.name + ' '}`) + }else{ + + own_her.push( { text: command.name + ' ', @@ -124,7 +153,7 @@ module.exports = { {text:'click on me to use me :)'}, ] },clickEvent:{ - action:"run_command",value:`${bot.options.commands.MainPrefix}${command.name}` + action:"run_command",value:`${bot.options.commands.prefixes[0]}${command.name}` }, // ${command.name}\nhashOnly:§c${command.hashOnly}§r\nconsoleOnly:§c${command.consoleOnly && !context.console}§r\n${command.description} @@ -133,8 +162,12 @@ module.exports = { } )//my w } + } // let valid else if (command.trustLevel === 1){ + if(!bot.options.Core.CorelessMode && !source.sources.console){ + t_rust.push(`&5${command.name + ' '}`) + }else { t_rust.push( { text: command.name + ' ', @@ -154,7 +187,7 @@ module.exports = { {text:'click on me to use me :)'}, ] },clickEvent:{ - action:"run_command",value:`${bot.options.commands.MainPrefix}${command.name}` + action:"run_command",value:`${bot.options.commands.prefixes[0]}${command.name}` }, // ${command.name}\nhashOnly:§c${command.hashOnly}§r\nconsoleOnly:§c${command.consoleOnly && !context.console}§r\n${command.description} @@ -163,10 +196,14 @@ module.exports = { } ) + } //my w } else if (command.trustLevel === 0){ - pub_lick.push( + if (!bot.options.Core.CorelessMode && !source.sources.console){ + pub_lick.push(`&b${command.name + ' '}`) + } else{ + pub_lick.push( { text: command.name + ' ', color: '#00FFFF', @@ -185,39 +222,58 @@ module.exports = { {text:'click on me to use me :)'}, ] },clickEvent:{ - action:"suggest_command",value:`${bot.options.commands.MainPrefix}${command.name}`} + action:"suggest_command",value:`${bot.options.commands.prefixes[0]}${command.name}`} }) - // copypasted from below, and removed stuff that wont work in the console + } - //{command.consoleOnly && !source.sources.console - //${command.description} - - // for (const command of context.bot.commandManager.getCommands()) { - // if (command.consoleOnly && !context.console) continue } - // console.log(pub_lick) - // console.log(t_rust) + } + function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} - // i could do context.source.sources.console - // but i want to do it like this - // if its buggy change to that +// Use the sleep function with async/await +/*async function main() { + console.log("Before sleep"); + await sleep(1000); // Wait for one second + console.log("After sleep"); +} +*/ const isConsole = context.source.player ? false : true - if(isConsole) { + if(source.sources.console) { // mabe idk const length = context.bot.commandManager.commandlist.length - context.source.sendFeedback([cmd, 'Commands (', length, ') ', category, ...pub_lick, t_rust, own_her, cons_ole], false) - } else { + bot.console.info(bot.getMessageAsPrismarine([cmd, 'Commands (', length, ') ', category, ...pub_lick, t_rust, own_her, cons_ole])?.toAnsi(), false)//[cmd, 'Commands (', length, ') ', category, ...pub_lick, t_rust, own_her, cons_ole] + } else if (!bot.options.Core.CorelessMode) { + + const length = context.bot.commandManager.commandlist.filter(c => c.trustLevel != 3).length + + + bot.chat('Commands (' + length + ') (&bPublic &f| &5Trusted &f| &4Owner&f)') + await sleep(1000) + bot.chat(`${pub_lick}`) + await sleep(1000) + bot.chat(`${t_rust}`) + await sleep(1000) + bot.chat(`${own_her}`) + + + }else {//+ t_rust + own_her const length = context.bot.commandManager.commandlist.filter(c => c.trustLevel != 3).length //trustlevel - context.source.sendFeedback([cmd, 'Commands (', length, ') ', category, ...pub_lick, t_rust ,own_her], false) - - // bot.tellraw([own_her]) + source.sendFeedback([cmd, 'Commands (', JSON.stringify(length), ') ', category, ...pub_lick, t_rust ,own_her], false) + } + // bot. + /* + bot.tellraw([pub_lick]) + bot.tellraw([t_rust]) + bot.tellraw([own_her]) + */ //console.log(t_rust) }// } } -} \ No newline at end of file diff --git a/commands/info.js b/commands/info.js index 6f5f45a..74f7126 100644 --- a/commands/info.js +++ b/commands/info.js @@ -1,7 +1,7 @@ const CommandError = require("../CommandModules/command_error"); const path = require("path"); -const fs = require("fs/promises"); +const fs = require("fs"); const packageJSON = require("../package.json"); module.exports = { @@ -22,16 +22,33 @@ module.exports = { color: "white", with: [{ color: "gold", text: "Info Cmd" }], }; - + function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} const buildstring = process.env["buildstring"]; const foundationbuildstring = process.env["FoundationBuildString"]; const source = context.source; - switch (args[0]) { + const ChatMessage = require('prismarine-chat')(bot.options.version) + switch (args[0]) { case "version": const discordJSVersion = packageJSON.dependencies["discord.js"]; const MinecraftProtocolVersion = packageJSON.dependencies["minecraft-protocol"]; - + +if(!bot.options.Core.CorelessMode){ + bot.chat(ChatMessage.fromNotch(`${process.env["buildstring"]}`).toMotd().replaceAll('§', '&')) + await sleep(1000) + + bot.chat(`${process.env["FoundationBuildString"]}`) + await sleep(1000) + bot.chat('Bot Release: 11/22/2022') +await sleep(1000) + bot.chat(`BotEngine: Node-Minecraft-Protocol @${MinecraftProtocolVersion}`) + await sleep(1000) + bot.chat(`Discord.js ${discordJSVersion}`) + await sleep(1000) + bot.chat(`Node JS Version ${process.version}`) +}else{ context.source.sendFeedback({ color: "gray", text: `${process.env["buildstring"]}`, @@ -92,6 +109,7 @@ module.exports = { color: "gray", text: `Node js Version @${process.version}`, }); +} // context.source.sendFeedback({color: 'gray', text:`npm Version:@${npmVersion}`}) break; @@ -105,7 +123,10 @@ module.exports = { ); break; case "discord": - source.sendFeedback({ + if(!bot.options.Core.CorelessMode){ + bot.chat(`${bot.options.discord.invite}`) + }else { + source.sendFeedback({ text: bot.options.discord.invite, color: "gray", translate: "", @@ -123,11 +144,33 @@ module.exports = { value: `${bot.options.discord.invite}`, }, }); - + } break; case "serverinfo": const os = require("os"); - context.source.sendFeedback({ + if(!bot.options.Core.CorelessMode){ + bot.chat(`Hostname: ${os.hostname()}`) + await sleep(1000) + bot.chat(`Working Directory: ${path.join(__dirname, "..")}`) + await sleep(1000) + bot.chat(`OS architecture: ${os.arch()}`) + await sleep(1000) + bot.chat(`OS platform: ${os.platform()}`) + await sleep(1000) + bot.chat(`OS name ${os.version()}`) + await sleep(1000) + bot.chat(`Kernal Version: ${os.release()}`) + await sleep(1000) + bot.chat(`CPU cores ${os.cpus().length}`) + await sleep(1000) + bot.chat(`CPU Model: ${os.cpus()[0].model}`) + await sleep(1000) + bot.chat(`Server Memory Usage ${Math.floor( + os.freemem() / 1048576)} MiB / ${Math.floor(os.totalmem() / 1048576)} MiB`) + }else { + + + context.source.sendFeedback({ color: "gray", text: `Hostname: ${os.hostname()}`, }); @@ -146,6 +189,10 @@ module.exports = { context.source.sendFeedback({ color: "gray", text: `OS name: ${os.version()}`, + }); + context.source.sendFeedback({ + color: "gray", + text: `Kernal Version: ${os.release()}`, }); context.source.sendFeedback({ color: "gray", @@ -168,9 +215,66 @@ module.exports = { os.freemem() / 1048576, )} `,color:'gray'},{text: `MiB / ${Math.floor(os.totalmem() / 1048576)} MiB`, color:'gray'}], }); + } + + /* +`Server Memory Usage `, color:'gray'},{text:`${Math.floor( + os.freemem() / 1048576, + )} `,color:'gray'},{text: `MiB / ${Math.floor(os.totalmem() / 1048576)} MiB + */ break; case "logininfo": - source.sendFeedback({ + if (!bot.options.Core.CorelessMode){ + bot.chat(`Bot Username: ${bot.username}`) + await sleep(1000) + bot.chat(`Bot uuid "${bot.uuid}"`) + await sleep(1000) + bot.chat(`Minecraft Java Version: ${bot.version}`) + await sleep(1000) + bot.chat(`Server: "${bot.options.host}:${bot.options.port}"`) + await sleep(1000) + bot.chat(`Prefixes: ${bot.options.commands.prefixes.join(', ')}`) + await sleep(1000) + bot.chat(`Discord Prefix: "${bot.options.discord.commandPrefix}"`) + await sleep(1000) + bot.chat(`Discord Username: "${bot.discord.client.user.username}#${bot.discord.client.user.discriminator}"`) + await sleep(1000) + bot.chat(`Discord Channel: ${bot.discord.channel.name}`) + await sleep(1000) + bot.chat(`ConsoleServer:"${bot.console.consoleServer}"`) + await sleep(1000) + const amonger2 = bot.bots.map((eachBot) => eachBot.options.host + "\n"); + const port2 = bot.bots.map((eachBot) => eachBot.options.port); + + if (amonger2.length === 0) { + const list = []; + for (const host of bots) { + if (list.length !== 0) { + list.push(host.name); + } + } + } + bot.chat(`Servers in Config ${amonger2.length}`); + + + + /* +const amonger = bot.bots.map((eachBot) => eachBot.options.host + "\n"); + const port = bot.bots.map((eachBot) => eachBot.options.port); + + if (amonger.length === 0) { + const list = []; + for (const host of bots) { + if (list.length !== 0) { + list.push(host.name); + } + } + } + source.sendFeedback({ text: `Servers in Config ${amonger.length}` }); + + */ + }else{ + source.sendFeedback({ text: `Bot Username: "${bot.username}"`, color: "gray", }); @@ -187,17 +291,10 @@ module.exports = { }); source.sendFeedback({ - text: `Main Prefix: "${bot.options.commands.MainPrefix}"`, - color: "gray", - }); - source.sendFeedback({ - text: `Secondary Prefix: "${bot.options.commands.SecondaryPrefix}"`, - color: "gray", - }); - source.sendFeedback({ - text: `Tertiary Prefix: "${bot.options.commands.TertiaryPrefix}"`, + text: `Prefixes: ${bot.options.commands.prefixes.join(', ')}`, color: "gray", }); + source.sendFeedback({ text: `Discord Prefix: "${bot.options.discord.commandPrefix}"`, color: "gray", @@ -228,72 +325,59 @@ module.exports = { } } source.sendFeedback({ text: `Servers in Config ${amonger.length}` }); - /* if (query.length === 0) { - const list = [] - for (const host of bots) { - if (list.length !== 0) list.push({ text: ', ', color: 'gray' })// list.push(info.name) - list.push(info.name) - } - - context.source.sendFeedback([], false) - return - }*/ - /* - if (query.length === 0) { - const list = [] - - for (const info of bots) { - if (list.length !== 0) list.push({ text: ', ', color: 'gray' })// list.push(info.name) - list.push(info.name) - - } - - context.source.sendFeedback(['Known bots (', bots.length, ') - ', ...list], false) - return - } - - */ - - //real - /* - const util = fs.readdir('./util') - source.sendFeedback({text:`Util Files loaded: ${util.length}`, color:'gray'}) - - const modules = fs.readdir('./modules') - source.sendFeedback({text:`Modules Files loaded: ${modules.length}`, color:'gray'}) - const commands = fs.readdir('./commands') - source.sendFeedback({text:`Commands Files loaded: ${commands.length}`, color:'gray'}) - const CommandModules = fs.readdir('./CommandModules') - source.sendFeedback({text:`CommandModules Files loaded: ${CommandModules.length}`, color:'gray'}) - const chat = fs.readdir('./chat') - source.sendFeedback({text:`Chat Files loaded: ${chat.length}`, color:'gray'}) - /* - const = '../' - fs.readdir(, (err, files) => { - source.sendFeedback({text:` Files loaded: ${file.length}`, color:'gray'}) - }); - */ - - /*context.source.sendFeedback({ - translate: '\n %s \n %s \n %s \n %s \n %s \n %s \n %s \n %s', - with: [ - { color: "gray", text: `Bot Username: "${bot.username}"`}, - { color: "gray", text: `Bot uuid: "${bot.uuid}"`, clickEvent: {action:"copy_to_clipboard", value: `${context.bot.uuid}`}}, - { color: "gray", text: `Minecraft Java Version: "${bot.version}"`}, - { color: "gray", text: `Server: "${bot.host}:${bot.port}"`}, - { color: "gray", text: `Prefix: "${bot.options.commands.prefix}"`}, - { color: "gray", text: `Discord Prefix: "${bot.options.discord.commandPrefix}"`}, - { color: "gray", text: `Discord Username: "${bot.discord.client.user.username}#${bot.discord.client.user.discriminator}"`}, - { color: "gray", text: `ConsoleServer:"${bot.console.consoleServer}"`} - ] - }); - - */ - // clickevent: { action:"open_url", value: `${context.bot.discord.invite}`}, - break; + case "loaded": + + const util = "./util"; + const modules = "./modules"; + const commands = "./commands"; + const CommandModules = "./CommandModules"; + + const chat = "./chat"; + if (!bot.options.Core.CorelessMode){ +fs.readdir(util, (err, files) => { + bot.chat(`Util files loaded: ${files.length}`); +}); + await sleep(1000) + fs.readdir(modules, (err, files) => { + bot.chat(`Modules files loaded: ${files.length}`); +}); + await sleep(1000) + fs.readdir(commands, (err, files) => { +bot.chat(`Command files loaded: ${files.length}`); +}); + await sleep(1000) + fs.readdir(CommandModules, (err, files) => { + bot.chat(`Command Module files loaded: ${files.length}`); +}); + await sleep(1000) + fs.readdir(chat, (err, files) => { + bot.chat(`Chat files loaded: ${files.length}`); +}); + }else { + fs.readdir(util, (err, files) => { + source.sendFeedback({text:`Util files loaded: ${files.length}`}); +}); + + fs.readdir(modules, (err, files) => { + source.sendFeedback({text:`Modules files loaded: ${files.length}`}); +}); + + fs.readdir(commands, (err, files) => { + source.sendFeedback({text:`Command files loaded: ${files.length}`}); +}); + + fs.readdir(CommandModules, (err, files) => { + source.sendFeedback({text:`Command Module files loaded: ${files.length}`}); +}); + + fs.readdir(chat, (err, files) => { + source.sendFeedback({text:`Chat files loaded: ${files.length}`}); +}); + } + break; case "test": // bot.tellraw('test') // const porta = bot.bots.map(eachBot => eachBot.options.port) @@ -333,16 +417,32 @@ module.exports = { } var uptime = process.uptime(); - +if(!bot.options.Core.CorelessMode){ + bot.chat(`Bot Uptime: ${format(uptime)}`) +} else { + source.sendFeedback({ color: "gray", text: `Bot Uptime: ${format(uptime)}`, }); - +} break; case "creators": - source.sendFeedback({ + if(!bot.options.Core.CorelessMode){ + bot.chat('Thank you all that helped!') + await sleep(1000) + bot.chat(`&4Parker&02991`) + await sleep(1000) + bot.chat('&2_ChipMC_') + await sleep(1000) + bot.chat('&echayapak') + await sleep(1000) + bot.chat('&d_yfd') + await sleep(1000) + bot.chat('&6Poopcorn (Poopbob???)') + }else{ + source.sendFeedback({ color: "gray", text: "Thank you to all that helped!", }); @@ -448,50 +548,16 @@ module.exports = { }, }); source.sendFeedback({ text: "Poopcorn(Poopbob???)", color: "gold" }); - - /* - text:bot.options.discord.invite, - color:'gray', - translate:"", - hoverEvent:{ - action:"show_text", - value:[ - { - text:'click here to join!', - color:'gray', - - } - ] - },clickEvent:{ - action:"open_url",value:`${bot.options.discord.invite}` - } - }) - */ - /* - context.source.sendFeedback({ - translate: '\n %s \n %s%s \n %s \n %s \n %s \n %s \n %s \n %s \n %s \n %s \n %s', - with: [ - { color: 'gray', text: 'Thank you to all that helped!' }, - { color: 'dark_red', text: 'Parker' }, - { color: 'black', text: '2991' }, - - { color: 'dark_green', text: '_ChipMC_' }, - - { color: 'yellow', text: 'chayapak' }, - - { color: 'light_purple', text: '_yfd' }, - { color: 'yellow', text: 'ChomeNS Discord Server: https://discord.gg/xdgCkUyaA4' }, - { color: 'aqua', text: 'FNFBoyfriendBot Discord Server: https://discord.gg/GCKtG4erux' }, - { color: 'green', text: '(sadly chip doesnt have a discord server) _ChipMC_s Website https://chipmunk.land' }, - { color: 'light_purple', text: '_yfds discord server: https://discord.gg/BKYKBxfDrs' }, - { color: 'yellow', text: 'chayapaks discord username: chayapak' }, - { color: 'green', text: '_ChipMC_s discord username: chipmunkmc' }, - ] - }); -*/ + } + break; default: - context.source.sendError([ + if (!bot.options.Core.CorelessMode){ + bot.chat('&4Invalid action') + await sleep(500) + bot.chat('the usages are version, discord, serverinfo, logininfo, uptime, creators') + } + context.source.sendError([ cmd, { text: "Invalid action", color: "dark_red", bold: false }, ]); diff --git a/commands/kick.js b/commands/kick.js index 0489dfb..2737336 100644 --- a/commands/kick.js +++ b/commands/kick.js @@ -13,8 +13,8 @@ module.exports = { // throw new CommandError('temp disabled') //throw new CommandError('command temporarily disabled until hashing is implemented') const args = context.arguments - - if (args[0] === 'clear' || args[0] === 'stop') { +if (!args && !args[0] && !args[1]) return + if (args[2] === 'clear' || args[2] === 'stop') { clearInterval(this.timer) this.timer = null @@ -24,7 +24,7 @@ module.exports = { // if (this.timer !== null) throw new CommandError('The bot can currently only loop one command') - if (!args && !args[0] && !args[1]) return // anti fard + // anti fard const target = context.player//let me hashonly it rq this.timer = setInterval(function() { // Wait, is this command public? diff --git a/commands/list.js b/commands/list.js index da28ef5..c7de5aa 100644 --- a/commands/list.js +++ b/commands/list.js @@ -5,7 +5,7 @@ module.exports = { description:['check the player list'], trustLevel: 0, aliases:['playerlist', 'plist', 'pl'], - execute (context) { + async execute (context) { const bot = context.bot const args = context.arguments const players = bot.players @@ -31,11 +31,44 @@ throw new CommandError({translate:"Too many Arguments!", color:"red"}) } component.pop() +function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} + /* + for (const player of players) { + component.push({ + translate: '%s \u203a %s [%s] %s', + with: [ + + player.displayName ?? player.profile.name, + player.uuid, + {text: `Ping: ${player.latency}`, color:'green'}, + player.gamemode + ] + }) + component.push('\n') + } + */ + if(source.sources.console){ + + bot.console.info(component) + + }else + if(!bot.options.Core.CorelessMode){ + + const ChatMessage = require('prismarine-chat')(bot.options.version) +for (const player of players){ + + bot.chat(ChatMessage.fromNotch(await sleep(500) ?? player.displayName ?? player.profile.name ).toMotd().replaceAll('§', '&') + `\u203a ${player.uuid} Ping: [&a${player.latency}&f]`) +} +}else{ + source.sendFeedback(component, false) + } } - +} diff --git a/commands/netmsg.js b/commands/netmsg.js index 2ab2b12..79c4782 100644 --- a/commands/netmsg.js +++ b/commands/netmsg.js @@ -17,11 +17,44 @@ module.exports = { const args = context.arguments const bot = context.bot - + const ChatMessage = require('prismarine-chat')(bot.options.version) const source = context.source - const player = context.source.player.displayName + //const player = context.source.player.displayName //throw n - const component = { + + + // context.source.player.displayName ?? context.source.player.profile.name, + /* + function tryParse (json) { + try { + return JSON.parse(json) + } catch (error) { + return { text: '' } + } +} + *///obj + /* + const amogus2 = {text:`${JSON.stringify(context.source.player.displayName ?? context.source.player.profile.name)}`} + + bot.tellraw({text:'amogus ' + JSON.parse(context.source.player.displayName)}) + */ //context.source.sendFeedback({text:`Hello, World!, Player: ${player}, uuid: ${uuid}, Argument: ${message}`}) + if (!message[0]) { + + context.source.sendFeedback({text:'Message is empty', color:'red'}, false) + if(source.sources.console && !bot.options.Core.CorelessMode){ + + for (const eachBot of bot.bots) + + eachBot.chat(`[${bot.options.host}:${bot.options.port}] ${ChatMessage.fromNotch(bot.options.username).toMotd().replaceAll('§', '&')} &f› ${message}`) + } + } else if (!bot.options.Core.CorelessMode && !source.sources.console) { + + + for (const eachBot of bot.bots) + + eachBot.chat(`[${bot.options.host}:${bot.options.port}] ${ChatMessage.fromNotch(context.source.player.displayName ?? context.source.player.profile.name).toMotd().replaceAll('§', '&')} &f› ${message}`)// + }else if(source.sources.console){ + const component = { translate: '[%s] [%s] %s \u203a %s', with: [ { @@ -69,36 +102,84 @@ module.exports = { }, -context.source.player.displayName ?? context.source.player.profile.name, +bot.username, //entry.displayName {text:message} ]//command.split(' ')[0] } + + for (const eachBot of bot.bots) + eachBot.tellraw(component) + + }else if(bot.options.Core.CorelessMode && !source.sources.console){ + + const component = { + translate: '[%s] [%s] %s \u203a %s', + with: [ + { + translate: '%s%s%s', + bold:false, + with: [ + { + text: 'FNF', + bold: true, + color: 'dark_purple' - // context.source.player.displayName ?? context.source.player.profile.name, - /* - function tryParse (json) { - try { - return JSON.parse(json) - } catch (error) { - return { text: '' } - } -} - *///obj - /* - const amogus2 = {text:`${JSON.stringify(context.source.player.displayName ?? context.source.player.profile.name)}`} + }, + { + text: 'Boyfriend', + bold: true, + color: '#00FFFF' + }, + { + text: 'Bot', + bold: true, + color: 'dark_red' + }, + ], + clickEvent: bot.options.Core.customName ? { action: 'open_url', value: bot.options.Core.customName } : undefined, + hoverEvent: { action: 'show_text', contents: `idfk what to put here` } + }, + { + text:`${bot.options.host}:${bot.options.port}`, + bold:false, + color:'white', + translate:"", + hoverEvent:{ + action:"show_text", + value:[ + { + text:`Server: ${bot.options.host}:${bot.options.port}`, + color:'white', + } + ], + clickEvent:{ + action:"copy_to_clipboard",value:`${bot.options.host}:${bot.options.port}`} + } + + + }, - bot.tellraw({text:'amogus ' + JSON.parse(context.source.player.displayName)}) - */ //context.source.sendFeedback({text:`Hello, World!, Player: ${player}, uuid: ${uuid}, Argument: ${message}`}) - if (!message[0]) { - context.source.sendFeedback({text:'Message is empty', color:'red'}, false) - } else { - for (const eachBot of bot.bots) eachBot.tellraw(component) - } + +context?.source?.player?.displayName ?? context?.source?.player?.profile?.name, + + //entry.displayName + {text:message} + ]//command.split(' ')[0] + } + + + for (const eachBot of bot.bots) + eachBot.tellraw(component) + + //eachBot.chat(`[${bot.options.host}:${bot.options.port}] ${context?.source?.player?.profile?.name} › ${message}`) + } } +} + /* translate:"", hoverEvent:{ diff --git a/commands/rc.js b/commands/rc.js index 89ed406..a69a9ca 100644 --- a/commands/rc.js +++ b/commands/rc.js @@ -1,12 +1,18 @@ +const CommandError = require('../CommandModules/command_error') module.exports = { name: 'rc', description:['refill the bots core'], trustLevel: 0, aliases:['refillcore'], execute (context) { - const bot = context.bot - + const bot = context.bot + +if (!bot.options.Core.CorelessMode){ + throw new CommandError('&4Could not fill core because Coreless mode is active!') +}else { + bot.core.refill() context.source.sendFeedback('Successfully Refilled Core!') } +} } \ No newline at end of file diff --git a/commands/say.js b/commands/say.js index 9141a39..9726303 100644 --- a/commands/say.js +++ b/commands/say.js @@ -41,10 +41,14 @@ module.exports = { { color: "green", text: `${message}` }, ], }; - +//if(!bot.options.Core.enabled){ + // throw new CommandError('&4Will not work because the core is not enabled please use the echo command') +//}else{ bot.tellraw([prefix]); - }, +} + // }, }; + //[%s] %s › %s //was it showing like that before? // just do text bc too sus rn ig diff --git a/commands/selfdestruct.js b/commands/selfdestruct.js index d9641b8..f0ce423 100644 --- a/commands/selfdestruct.js +++ b/commands/selfdestruct.js @@ -26,7 +26,8 @@ trustLevel: 2, return } - + + if (this.timer !== null) return this.timer = setInterval(function () { bot.core.run('day') diff --git a/commands/servereval.js b/commands/servereval.js index b34ed9c..d0849bc 100644 --- a/commands/servereval.js +++ b/commands/servereval.js @@ -4,7 +4,7 @@ module.exports = { description:['no'], trustLevel: 2, aliases:['svreval'], - execute (context, arguments, selector) { + async execute (context, arguments, selector) { const bot = context.bot // const args = context.arguments.join(' ') const source = context.source @@ -12,19 +12,39 @@ const source = context.source const { stylize } = require('../util/eval_colors') const util = require('util') const args = context.arguments - + const ChatMessage = require('prismarine-chat')(bot.options.version) const script = args.slice(1).join(' '); - if (!args && !args[0] && !args[1] && !args[2] && !args[3] && !args[4] ) return -try { + //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 + if(!bot.options.Core.CorelessMode && !source.sources.console){ + + 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) } source.sendFeedback({ text: util.inspect(eval(script), { stylize }).substring(0, 32700) }) source.sendFeedback({ text: `Script input: ${script}` }) -} catch (err) { - source.sendFeedback({ text: err.message, color: 'red' }) + } + } catch (err) { + if(!bot.options.Core.enabled && !source.sources.console){ + 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' }) source.sendFeedback({ text: `Script input: ${script}` }) } } } - +} /* try { diff --git a/commands/time.js b/commands/time.js index b249a7d..63bd08d 100644 --- a/commands/time.js +++ b/commands/time.js @@ -5,7 +5,7 @@ module.exports = { description:['check the time'], aliases:['clock', 'timezone'], trustLevel: 0, - execute (context) { + async execute (context) { const bot = context.bot const message = context.arguments.join(' ') const moment = require('moment-timezone') @@ -14,12 +14,25 @@ const source = context.source const timezone = args.join(' ') if (!moment.tz.names().map((zone) => zone.toLowerCase()).includes(timezone.toLowerCase())) { - throw new CommandError('Invalid timezone') + bot.chat('Invalid timezone') } const momented = moment().tz(timezone).format('dddd, MMMM Do, YYYY, hh:mm:ss A') const component = [{ text: 'The current date and time for the timezone ', color: 'white' }, { text: timezone, color: 'aqua' }, { text: ' is: ', color: 'white' }, { text: momented, color: 'green' }] + + if (!bot.options.Core.CorelessMode) { + function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); + } + bot.chat(`The current time and date for the timezone &b${timezone}`) + await sleep(1000) + bot.chat(`is:`) + await sleep(1000) + bot.chat(`&a${momented}`) + +}else{ source.sendFeedback(component) } } +} \ No newline at end of file diff --git a/commands/tpr.js b/commands/tpr.js index cd809e5..1972afa 100644 --- a/commands/tpr.js +++ b/commands/tpr.js @@ -1,5 +1,5 @@ const between = require('../util/between') - +const CommandError = require('../CommandModules/command_error') module.exports = { name: 'tpr', description:['teleport to a random place'], @@ -14,8 +14,12 @@ const source = context.source const x = between(-1_000_000, 1_000_000) const y = 100 const z = between(-1_000_000, 1_000_000) - source.sendFeedback(`Randomly Teleported: ${sender.profile.name} to x:${x} y:${y} z:${z} `) +if (!bot.options.Core.CorelessMode){ + throw new CommandError('Coreless mode is active can not execute command!') +}else{ + source.sendFeedback(`Randomly Teleported: ${sender.profile.name} to x:${x} y:${y} z:${z} `) bot.core.run(`tp ${sender.uuid} ${x} ${y} ${z}`) } } +} \ No newline at end of file diff --git a/commands/tps.js b/commands/tps.js index 8243d24..bce6ac7 100644 --- a/commands/tps.js +++ b/commands/tps.js @@ -12,14 +12,21 @@ module.exports = { const args = context.arguments switch (args[0]) { case 'on': - bot.tps.on() - + if(!bot.options.Core.CorelessMode){ + throw new CommandError('Coreless mode is active can not execute command!') + }else{ + bot.tps.on() + source.sendFeedback({text: 'TPSBar is now enabled', color:'green'}) - break + } + break case 'off': - bot.tps.off() + if(!bot.options.Core.CorelessMode){ + throw new CommandError('Coreless mode is active can not execute command!') + }else{ + bot.tps.off() source.sendFeedback({text:'TPSBar is now disabled', color:'red'}) - + } break default: throw new CommandError('Invalid argument') diff --git a/commands/translate.js b/commands/translate.js index 4593d6b..0cfa6a6 100644 --- a/commands/translate.js +++ b/commands/translate.js @@ -13,12 +13,21 @@ const bot = context.bot const args = context.arguments const amonger = args.slice(1).join(' '); const source = context.source - try { + const ChatMessage = require('prismarine-chat')(bot.options.version) + try { const res = await translate(args.slice(2).join(' '), { from: args.slice(1).join(' '), to: args[1] }) - bot.tellraw([{ text: 'Result: ', color: 'gold' }, { text: res.text, color: 'green' }]) - } catch (e) { + if(!bot.options.Core.CorelessMode){ + bot.chat(ChatMessage.fromNotch([{ text: 'Result: ', color: 'gold' }, { text: res.text, color: 'green' }]).toMotd().replaceAll('§', '&')) + }else{ + bot.tellraw([{ text: 'Result: ', color: 'gold' }, { text: res.text, color: 'green' }]) + } + } catch (e) { + if (!bot.options.Core.CorelessMode){ + bot.chat(ChatMessage.fromNotch({ text: e.toString(), color: 'red' }).toMotd().replaceAll('§', '&')) + }else{ source.sendFeedback({ text: e, color: 'red' }) } + } }, } diff --git a/commands/urban.js b/commands/urban.js index b6b2946..c8c8e9b 100644 --- a/commands/urban.js +++ b/commands/urban.js @@ -8,6 +8,7 @@ trustLevel: 0, async execute (context) { const source = context.source const args = context.arguments + const bot = context.bot const cmd = { translate: '[%s] ', bold: false, @@ -32,21 +33,33 @@ trustLevel: 0, { color: 'dark_gray', text: 'Definition text'}, ] } - +async function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} try { const definitions = await urban.define(args.join(' ')) const definitions2 = await urban.define(args.join(' ')) //const definitions2 = await urban.example(args.join(' ')) + //ChatMessage.fromNotch(await sleep(500) ?? player.displayName ?? player.profile.name ).toMotd().replaceAll('§', '&') + if(!bot.options.Core.CorelessMode){ + const ChatMessage = require('prismarine-chat')(bot.options.version) for (const definition of definitions) { - source.sendFeedback([cmd, example, { text: definition.example.replaceAll("\r", ""), color: 'gray' }, { text: ' - ', color: 'white' }]) + + +bot.chat(ChatMessage.fromNotch(await sleep(500) +?? [cmd, example, { text: definition.example.replaceAll("\r", ""), color: 'gray' }, { text: ' - ', color: 'white' }]).toMotd().replaceAll('§', '&')) + await sleep(500) + bot.chat(ChatMessage.fromNotch(await sleep(1000) ?? [cmd, definition5,{ text: definition.definition.replaceAll("\r", ""), color: 'gray' } ]).toMotd().replaceAll('§', '&')) + }//oh + }else{//?? + + for (const definition of definitions) { + + source.sendFeedback([cmd, example, { text: definition.example.replaceAll("\r", ""), color: 'gray' }, { text: ' - ', color: 'white' }]) source.sendFeedback([cmd, definition5,{ text: definition.definition.replaceAll("\r", ""), color: 'gray' } ]) } - urban.define(args.join(' ')).then((results) => { - source.sendFeedback([cmd,{text:`Definition: ${results[0].word}`, color:'dark_gray'}]) - source.sendFeedback([cmd,{text:`Author: ${results[0].author}`, color:'dark_gray'}]) - //source.sendFeedback(results[0].thumbs_down) - source.sendFeedback([cmd,{text:`👍 ${results[0].thumbs_up} | 👎 ${results[0].thumbs_down}`, color:'gray'}]) - + + //source.sendFeedback(results[0].written_on) @@ -54,15 +67,20 @@ trustLevel: 0, //source.sendFeedback(results[0].data) - }) + } // source.sendFeedback([cmd, { text: definitions2.replaceAll("\r", ""), color: 'white' }, { text: ' - ', color: 'white' }, { text: definition.definition.replaceAll("\r", ""), color: 'white' }]) //console.log(urban.define.definition.example(args.join(' '))) //text: definition.word text: definition.definition - } catch (e) { - source.sendFeedback([cmd,{ text: e.toString(), color: 'red' }]) + + } catch (e) { + if (!bot.options.Core.CorelessMode){ + const ChatMessage = require('prismarine-chat')(bot.options.version) + bot.chat(ChatMessage.fromNotch([cmd,{ text: e.toString(), color: 'red' }]).toMotd().replaceAll('§', '&')) + }else { + source.sendFeedback([cmd,{ text: e.toString(), color: 'red' }]) + } } - } } \ No newline at end of file diff --git a/commands/validate.js b/commands/validate.js index 3d8f00d..d2c4d11 100644 --- a/commands/validate.js +++ b/commands/validate.js @@ -12,13 +12,25 @@ const hash = bot.hash const ownerhash = bot.owner const discordHash = bot.hashing.hash if (args[0] === hash) { - source.sendFeedback({ text: 'Valid Hash', color: 'green' }) + if(!bot.options.Core.CorelessMode){ + bot.chat('&aValid Hash') + }else{ + source.sendFeedback({ text: 'Valid Hash', color: 'green' }) + } }else if (args[0] === ownerhash) { - source.sendFeedback({text: 'Valid OwnerHash', color:'green'}) + if(!bot.options.Core.CorelessMode){ + bot.chat('&aValid Owner Hash') + }else{ + source.sendFeedback({text: 'Valid Owner Hash', color:'green'}) } - else if (discordHash) { - source.sendFeedback({ text: 'Valid Hash', color: 'green' }) } + else if (discordHash) { + if(!bot.options.Core.CorelessMode){ + bot.chat('&aValid Hash') + }else{ + source.sendFeedback({ text: 'Valid Hash', color: 'green' }) + } + } } } //if (args[0] === hash) { \ No newline at end of file diff --git a/commands/wiki.js b/commands/wiki.js index 330f973..8fc1205 100644 --- a/commands/wiki.js +++ b/commands/wiki.js @@ -1,4 +1,5 @@ const wiki = require('wikipedia') // +const CommandError = require('../CommandModules/command_error') module.exports = { name: 'wiki', description:['wikipedia'], @@ -7,7 +8,12 @@ trustLevel: 0, async execute (context) { const source = context.source const args = context.arguments - const cmd = { + const bot = context.bot + const ChatMessage = require('prismarine-chat')(bot.options.version) +function sleep(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); +} + const cmd = { translate: '[%s] ', bold: false, color: 'white', @@ -24,9 +30,18 @@ trustLevel: 0, /// console.log(summary) // source.sendFeedback({ text: JSON.stringify(summary), color: 'green' }) + if (!bot.options.Core.CorelessMode){ + bot.chat(ChatMessage.fromNotch(await sleep(500) +?? [cmd, { text:summary2, color: 'gray' }]).toMotd().replaceAll('§', '&')) + }else{ source.sendFeedback([cmd,{ text:`${summary2}`, color: 'green' }]) + } } catch (e) { + if(!bot.options.Core.CorelessMode){ + bot.chat(ChatMessage.fromNotch([cmd, { text: `${e.toString()}`, color: 'red' }]).toMotd().replaceAll('§', '&')) + }else{ source.sendFeedback([cmd, { text: `${e}`, color: 'red' }]) } } } +} \ No newline at end of file diff --git a/default.js b/default.js index 0419f71..b078aaf 100644 --- a/default.js +++ b/default.js @@ -3,38 +3,48 @@ module.exports = { bots: [ - { - host: "server ip here or comment this out and refer to the bot.js file", - version:"1.20.1",//version here - reconnectDelay: 6000, - username:username(), - console:true, - input: true, +{ + host: "serveriphere", + username:username(), + version:"1.20.2", + reconnectDelay: 6000, + + Console:{ + enabled: false, + filelogging:false, + }, + + + commands: { + prefixes: + ["!", "!", "!"] // are those the prefixes? + }, Core: { - customName:"core custom name here", - core: true, + customName:"corenamehere", + CorelessMode: false, interval:180000 - }, - discord: { - channelId: "discord channel ip here", - invite: "discord invite link here", - commandPrefix: "discord command prefix here" + }, + discord: { + channelId: "discordchannelidhere", + invite: "discordinvitelinkhere", + commandPrefix: "!" }, - selfcare: { - vanished: true, - unmuted: true, - prefix: true, - cspy: true, - tptoggle:true, - skin:true, - gmc:true, - op:true, - nickname:true, - username:true, - god: true, + selfcare: { + vanished: false, + unmuted: false, + prefix: false, + cspy: false, + tptoggle:false, + skin:false, + gmc:false, + op:false, + nickname:false, + username:false, + god: false, interval:500, } - }, + }, + ] } diff --git a/index.js b/index.js index b666ef2..46b5af5 100644 --- a/index.js +++ b/index.js @@ -21,7 +21,8 @@ function load() { bots.push(bot); bot.bots = bots; bot.options.username; - bot.loadModule = (module) => module(bot, options); + + bot.loadModule = (module) => module(bot, options); for (const filename of fs.readdirSync(path.join(__dirname, "modules"))) { try { @@ -89,6 +90,4 @@ async function checkConfig() { checkConfig(); -process.on("uncaughtException", (e) => { - console.log("uncaught " + e.stack); -}); + diff --git a/modules/bruhify.js b/modules/bruhify.js index a786071..9076186 100644 --- a/modules/bruhify.js +++ b/modules/bruhify.js @@ -3,7 +3,8 @@ const convert = require('color-convert') function bruhify (bot) { bot.bruhifyText = '' let startHue = 0 - const timer = setInterval(() => { + const ChatMessage = require('prismarine-chat')(bot.options.version) + const timer = setInterval(() => { if (bot.bruhifyText === '') return let tag = 'bruhify' let hue = startHue @@ -15,10 +16,15 @@ let tag = 'bruhify' component.push({ text: character, color: `#${color}` }) hue = (hue + increment) % 360 } + if (!bot.options.Core.CorelessMode){ + bot.chat(ChatMessage.fromNotch(component).toMotd().replaceAll('§', '&')) + startHue = (startHue + increment) % 360 + }else{ bot.core.run(`minecraft:title @a actionbar ${JSON.stringify(component)}`) startHue = (startHue + increment) % 360 - }, 100) + } + }, 100) bot.on('end', () => { // clearInterval(timer) diff --git a/modules/chat.js b/modules/chat.js index 4776704..6840c8f 100644 --- a/modules/chat.js +++ b/modules/chat.js @@ -4,6 +4,7 @@ const chipmunkmodChatParser = require('../chat/chipmunkmod') const chipmunkmodblackilykatverChatParser = require('../chat/chipmunkmodBlackilyKatVer') const typetextChatParser = require('../chat/chatTypeText') const typeemotetextChatParser = require('../chat/chatTypeEmote') +const creayunChatParser = require('../chat/creayun') const fs = require('fs') function tryParse (json) { try { @@ -19,7 +20,7 @@ function chat (bot, context) { ChatMessage = loadPrismarineChat(registry) }) - bot.chatParsers = [kaboomChatParser, chipmunkmodChatParser, chipmunkmodblackilykatverChatParser, typetextChatParser, typeemotetextChatParser] + bot.chatParsers = [kaboomChatParser, chipmunkmodChatParser, chipmunkmodblackilykatverChatParser, typetextChatParser, typeemotetextChatParser, creayunChatParser] bot.on('packet.profileless_chat', packet => { const message = tryParse(packet.message) @@ -256,7 +257,7 @@ function chat (bot, context) { } return })*/ - bot.on('parsed_message', data => { + /* bot.on('parsed_message', data => { if (data.type !== 'minecraft:chat') return const plainMessage = bot.getMessageAsPrismarine(data.contents)?.toString() @@ -271,7 +272,7 @@ function chat (bot, context) { if (plainMessage.startsWith('qwerty')) { bot.chat(' qwerty') } return -}) +})*/ /* bot.on('parsed_message', data => { if (data.type !== 'minecraft:chat') return @@ -294,8 +295,13 @@ function chat (bot, context) { previousMessages: [] }) } - + bot.tellraw = (message, selector = '@a') => bot.core.run('minecraft:tellraw @a ' + JSON.stringify(message)) // ? Should this be here? -} - +}/* const timer = setInterval(() => { + bot.chat(`Join the FNFBoyfriendBot discord ${bot.options.discord.invite}`) + }, 200000) + const timer1 = setInterval(() => { + bot.chat('') + }, 300000) +*/ module.exports = chat diff --git a/modules/chat_command_handler.js b/modules/chat_command_handler.js index 187e075..9a625c7 100644 --- a/modules/chat_command_handler.js +++ b/modules/chat_command_handler.js @@ -1,89 +1,109 @@ const CommandSource = require("../CommandModules/command_source"); const CommandError = require("../CommandModules/command_error"); - +//can i change the var? function chat_command_handler(bot) { + let ratelimit = 0 bot.on("parsed_message", (data) => { if (data.type !== "minecraft:chat") return; - const plainMessage = bot.getMessageAsPrismarine(data.contents)?.toString(); - if ( - !plainMessage.startsWith(bot.commandManager.MainPrefix) && - !plainMessage.startsWith(bot.commandManager.SecondaryPrefix) && - !plainMessage.startsWith(bot.commandManager.TertiaryPrefix) - ) - return; - // else if (!plainMessage.startsWith(bot.commandManager.prefix2)) return - // MainPrefix: "~", - // SecondaryPrefix:'%', - //TertiaryPrefix:'@' + const prefixes = bot.options.commands.prefixes; - const command = plainMessage.substring( - bot.commandManager.MainPrefix.length || - plainMessage.substring( - bot.commandManager.SecondaryPrefix.length || - plainMessage.substring(bot.commandManager.TertiaryPrefix.length), - ), - ); // if the prefixes are the same length just make it 1 or the length - /* - lifes sus - */ - const source = new CommandSource( - data.sender, - { discord: false, console: false }, - true, - ); - source.sendFeedback = (message) => { - const prefix = { - translate: "[%s%s%s] \u203a ", - bold: false, - color: "dark_gray", - with: [ - { - color: "dark_purple", - text: "FNF", - bold: true, - hoverEvent: { - action: "show_text", - value: `${process.env["buildstring"]}\n${process.env["FoundationBuildString"]}`, - }, - clickEvent: bot.options.Core.customName - ? { action: "open_url", value: bot.options.Core.customName } - : undefined, - }, - { - color: "#00FFFF", - text: "Boyfriend", - bold: true, - clickEvent: bot.options.discord.invite - ? { action: "open_url", value: bot.options.discord.invite } - : undefined, - hoverEvent: { - action: "show_text", - value: `Bot Username: ${bot.username}\nBot UUID: ${bot.uuid}\nServer Host: ${bot.options.host}:${bot.options.port}\nBot Minecraft Java Version: ${bot.options.version}`, - }, - }, - { - color: "dark_red", - text: "Bot", - bold: true, - clickEvent: bot.options.discord.invite - ? { action: "open_url", value: "https://code.chipmunk.land" } - : undefined, - hoverEvent: { - action: "show_text", - value: "§aMan i like frogs - _ChipMC_", - }, - }, //§aMan i like frogs - _ChipMC_ + prefixes.map((prefix) => { + const plainMessage = bot + .getMessageAsPrismarine(data.contents) + ?.toString(); + if (!plainMessage.startsWith(prefix)) return; + // else if (!plainMessage.startsWith(bot.commandManager.prefix2)) return + // MainPrefix: "~", + // SecondaryPrefix:'%', + //TertiaryPrefix:'@' - { color: "green", text: command.split(" ")[0] }, - ], + const command = plainMessage.substring(prefix.length); // if the prefixes are the same length just make it 1 or the length + /* + lifes sus + */ + const source = new CommandSource( + data.sender, + { discord: false, console: false }, // + + ); + source.sendFeedback = (message) => { + const prefix = { + translate: "[%s%s%s] \u203a ", + bold: false, + color: "dark_gray", + with: [ + { + color: "dark_purple", + text: "FNF", + bold: true, + hoverEvent: { + action: "show_text", + value: `${process.env["buildstring"]}\n${process.env["FoundationBuildString"]}`, + }, + clickEvent: bot.options.Core.customName + ? { action: "open_url", value: bot.options.Core.customName } + : undefined, + }, + { + color: "#00FFFF", + text: "Boyfriend", + bold: true, + clickEvent: bot.options.discord.invite + ? { action: "open_url", value: bot.options.discord.invite } + : undefined, + hoverEvent: { + action: "show_text", + value: `Bot Username: ${bot.username}\nBot UUID: ${bot.uuid}\nServer Host: ${bot.options.host}:${bot.options.port}\nBot Minecraft Java Version: ${bot.options.version}`, + }, + }, + { + color: "dark_red", + text: "Bot", + bold: true, + clickEvent: bot.options.discord.invite + ? { action: "open_url", value: "https://code.chipmunk.land" } + : undefined, + hoverEvent: { + action: "show_text", + value: "§aMan i like frogs - _ChipMC_", + }, + }, //§aMan i like frogs - _ChipMC_ + + { color: "green", text: command.split(" ")[0] }, + ], + }; + + bot.tellraw(["", prefix, message]); }; - - bot.tellraw(["", prefix, message]); - }; - - bot.commandManager.executeString(source, command); - }); +try{ + + ratelimit++ + setTimeout(() => { + ratelimit-- + }, 1000) + if (ratelimit > 3) { // ,. +if(!bot.options.Core.CorelessMode){ + bot.chat('&4You are using commands to fast!') +}else { + source.sendFeedback({text:'You are using commands to fast!',color:'dark_red'}) + // this isn't blocking running the command you know that right? } + } else { + bot.commandManager.executeString(source, command); + }//oh real + //can i change the variable name so its name isnt confusing? +}catch(e){ + console.log(e.stack) + + + + //then where to move this? + + + }; + }); +})// +} module.exports = chat_command_handler; diff --git a/modules/command_core.js b/modules/command_core.js index 65cbdd4..6533551 100644 --- a/modules/command_core.js +++ b/modules/command_core.js @@ -81,7 +81,7 @@ async function command_core (bot, options) { } return }) */ - if (!bot.options.Core.core) return + if (!bot.options.Core.CorelessMode) return bot.on('move', () => { bot.core.move(bot.position) //setTimeout(() => bot.core.run('say hi'), 100) diff --git a/modules/command_loop_manager.js b/modules/command_loop_manager.js index b86e25a..e06b5c9 100644 --- a/modules/command_loop_manager.js +++ b/modules/command_loop_manager.js @@ -3,9 +3,17 @@ function command_loop_manager (bot, options) { list: [], add (command, interval) { - this.list.push({ timer: setInterval(() => bot.core.run(command), interval), command, interval }) + + this.list.push({ timer: setInterval(() => bot.core.run(command), interval), command, interval }) }, + /* + if (message.startsWith('/')) { + bot.command(message.substring(1)) + return + } + bot.chat(message) + */ remove (index) { clearInterval(this.list[index].timer) }, diff --git a/modules/command_manager.js b/modules/command_manager.js index 3b56e74..dbecff2 100644 --- a/modules/command_manager.js +++ b/modules/command_manager.js @@ -3,11 +3,8 @@ const path = require("path"); const CommandError = require("../CommandModules/command_error.js"); //check command_source //it would be both the command_source.js and command_manager.js files -function command_manager(bot, options) { +async function command_manager(bot, options) { bot.commandManager = { - MainPrefix: options.commands.MainPrefix ?? "default", - SecondaryPrefix: options.commands.SecondaryPrefix ?? "default", - TertiaryPrefix: options.commands.TertiaryPrefix ?? "default", commands: {}, commandlist: [], //ohio @@ -18,19 +15,27 @@ function command_manager(bot, options) { timeZone: "America/CHICAGO", }); try { - if (!command || !command.execute) - throw new CommandError({ - translate: `Unknown command %s. Type "${bot.options.commands.MainPrefix}help" for help or click on this for the command`, + if (!bot.options.Core.CorelessMode){ + if (!command || !command.execute) { + throw new CommandError(`Unknown command ${commandName}. Type "${bot.options.commands.prefixes[0]}help" for help`) + } +}else { + if (!command || !command.execute) // bot.options.command.prefixes[0] + throw new CommandError({ // sus + translate: `Unknown command %s. Type "${bot.options.commands.prefixes[0]}help" for help or click on this for the command`, with: [commandName], - clickEvent: bot.options.Core.customName - ? { + clickEvent: 'https://discord.gg' + + ? {//fr + // theme moment action: "suggest_command", - value: `${bot.options.commands.MainPrefix}help`, + value: `${bot.options.commands.prefixes[0]}help`, } : undefined, }); //ohio - - if (command.trustLevel > 0) { + } + + if (command?.trustLevel > 0) { const event = source?.discordMessageEvent; const roles = event?.member?.roles?.cache; @@ -52,15 +57,21 @@ function command_manager(bot, options) { }); if ( !source?.sources?.discord && + !source?.sources?.console && command.trustLevel === 1 && args[0] !== bot.hash && args[0] !== bot.owner && args[0] !== bot.hashing.hash - ) - throw new CommandError({ + ) if (!bot.options.Core.CorelessMode){ + + throw new CommandError('&4Invalid Hash or Invalid Owner Hash') + // throw new CommandError('') + }else{ + 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", @@ -104,6 +115,7 @@ function command_manager(bot, options) { command.trustLevel === 2 && !roles?.some((role) => role.name === "FNFBoyfriendBot Owner") ) + throw new CommandError({ text: "You are not the Owner!", color: "dark_red", @@ -111,45 +123,64 @@ function command_manager(bot, options) { const owner = `${args[0]}`; if ( !source?.sources?.discord && + !source?.sources?.console && command.trustLevel === 2 && owner !== bot.owner ) + if (!bot.options.Core.CorelessMode){ + + throw new CommandError('&4Invalid Owner Hash') + }else{ throw new CommandError({ text: "Invalid Owner Hash", color: "dark_red", }); - + } if (command.trustLevel === 3 && !source?.sources?.console) + if(!bot.options.Core.CorelessMode){ + throw new CommandError('&9This command can only be execute via console') + }else{ throw new CommandError({ translate: "This command can only be executed via console", color: "blue", }); } - return command.execute({ bot, source, arguments: args }); + } + return command?.execute({ bot, source, arguments: args }); } catch (error) { const now = new Date().toLocaleString("en-US", { timeZone: "America/CHICAGO", }); bot.console.warn(error.stack); - if (error instanceof CommandError) source.sendError(error._message); - - else - source.sendError({ + + if (!bot.options.Core.CorelessMode){ + if (error instanceof CommandError) + bot.chat(error._message) + else bot.chat('a error has occured!') + } else { + if (error instanceof CommandError) + source.sendError(error._message) + else source.sendError({ translate: "An Error has occured because the bot shot itself 🔫", color: "red", hoverEvent: { action: "show_text", contents: String(error.stack) }, }); + } + // + + + if (source.sources.discord) { source.sendError(error); } } - }, + }, + executeString(source, command) { const [commandName, ...args] = command.split(" "); return this.execute(source, commandName, args); }, - register(command) { this.commands[command.name] = command; diff --git a/modules/console.js b/modules/console.js index 88dff26..66b0619 100644 --- a/modules/console.js +++ b/modules/console.js @@ -1,8 +1,9 @@ const CommandSource = require("../CommandModules/command_source"); -//const logger = require('../util/logger') - +// idk if it's modules or utils though +//modules is automatically loaded function Console(bot, options, context, source) { - bot.console = { + let ratelimit = 0 + bot.console = { readline: null, username: bot.username, consoleServer: "all", @@ -36,12 +37,19 @@ function Console(bot, options, context, source) { // what does it have to be if (line.startsWith("")) { - return bot.commandManager.executeString( + if(!bot.options.Core.CorelessMode){ + + return bot.commandManager.executeString( + bot.console.source, + "echo " + line.substring(0), + ) + }else { + return bot.commandManager.executeString( bot.console.source, "console " + line.substring(0), ); } - + } //bot.commandManager.executeString(bot.console.source, line) }); @@ -112,11 +120,11 @@ function Console(bot, options, context, source) { discord: false, }); bot.console.source.sendFeedback = (message) => { - - const ansi = bot.getMessageAsPrismarine(message)?.toAnsi(); + + const ansi = bot.getMessageAsPrismarine(message)?.toAnsi(); - if (!bot.options.input) return; - if (!bot.options.console) return; + if (!bot.options.Console.input) return; + if (!bot.options.Console.enabled) return; bot.console.info(ansi); }; @@ -131,6 +139,7 @@ function Console(bot, options, context, source) { } return; }); + bot.on("message", (message) => { function log(...args) { rl.output.write("\x1b[2K\r"); @@ -150,7 +159,7 @@ function Console(bot, options, context, source) { }; const lang = require(`../util/language/lolus.json`); const ansi = bot.getMessageAsPrismarine(message)?.toAnsi(lang); - const string = bot.getMessageAsPrismarine(message)?.toString(); + const string = bot.getMessageAsPrismarine(message)?.toString(lang); const now = new Date().toLocaleString("en-US", { timeZone: "America/CHICAGO", @@ -163,11 +172,59 @@ function Console(bot, options, context, source) { }); - if (!bot.options.input) return; - if (!bot.options.console) return; - bot.console.logs(`${ansi}`); - }); - }, - }; + // if (!bot.options.Console.input) return; + if (!bot.options.Console.enabled) return; + + ratelimit++ + setTimeout(() => { + ratelimit-- + }, 1000) + if (ratelimit > 35) { // ,. + + bot.console.logs = function () {} + } else { + //bot.console.log(`${ansi}`); + //oh real + + //can i change the variable name so its name isnt confusing? + + bot.console.logs(`${ansi}`); + + // logger(`<${time} ${date}> [${bot.options.host}:${bot.options.port}] [LOGS]: ${string}`) + if (bot.console && bot.console.filelogger) { + bot.console.filelogger(`<${time} ${date}> [${bot.options.host}:${bot.options.port}] [LOGS]: ${string}`) + + }//nothing is logging to the file + /* + try{ + + ratelimit++ + setTimeout(() => { + ratelimit-- + }, 1000) + if (ratelimit > 5) { // ,. + + source.sendFeedback({text:'You are using commands to fast!',color:'dark_red'}) + // this isn't blocking running the command you know that right? + } else { + bot.commandManager.executeString(source, command); + }//oh real + + //can i change the variable name so its name isnt confusing? +}catch(e){ + console.log(e.stack) + + + + //then where to move this? + + + }; + */ + }; + }) + } + } } + module.exports = Console; diff --git a/modules/discord.js b/modules/discord.js index d40bbdd..68b7f81 100644 --- a/modules/discord.js +++ b/modules/discord.js @@ -14,7 +14,7 @@ function discord (bot, options) { bot.discord = { invite: options.discord?.invite } return } - +const ChatMessage = require('prismarine-chat')(bot.options.version) bot.discord = { client, channel: undefined, @@ -126,13 +126,15 @@ function discord (bot, options) { source.sendFeedback = message => { sendComponent(message) - console.log(message.content) + //console.log(message.content) } bot.commandManager.executeString(source, message.content.substring(bot.discord.commandPrefix.length)) return } - +if(!bot.options.Core.CorelessMode){ + bot.chat(`&8[&5FNF&bBoyfriend&4Bot &9Discord&8] ${message.member.displayName.replaceAll('\xa7', '&')}&f › ${message.content.replaceAll('\xa7', '&')}`) +}else{ bot.tellraw({ translate: '[%s] %s \u203a %s', with: [ @@ -171,7 +173,7 @@ function discord (bot, options) { }) } - + } client.on('messageCreate', messageCreate) bot.on('kick_disconnect', reason => { @@ -188,6 +190,9 @@ function discord (bot, options) { //sendDiscordMessage(reason) }) + bot.on('packet.login', (data) => { + sendDiscordMessage(`Connecting to ${bot.options.host}:${bot.options.port}`) + }) bot.on('end', reason => { sendDiscordMessage(JSON.stringify(reason)) @@ -202,15 +207,10 @@ function discord (bot, options) { //sendDiscordMessage(reason) }) - bot.on('parsed_message', data => { - if (data.type !== 'minecraft:chat') return - - const plainMessage = bot.getMessageAsPrismarine(data.contents)?.toString() - if (plainMessage.startsWith('purr')) { - bot.chat(' puuuuuuuuuurrrrrrrrrrrr~') - - } return -}) + process.on("uncaughtException", (e) => { + sendDiscordMessage("uncaught " + e.stack); +}); + /*bot.on('end', (reason, event) => { sendDiscordMessage('event:' + event) sendDiscordMessage('Reason:' + util.inspect(reason)) diff --git a/modules/logger.js b/modules/logger.js new file mode 100644 index 0000000..e90efa8 --- /dev/null +++ b/modules/logger.js @@ -0,0 +1,29 @@ +function consolefilelogger (bot, options, message) { + 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'); // idfk +const logFileName = `${timestamp}.txt`;//why is it not trying to find the folder tf +// i am having a stroke from this + if (!options.Console.filelogging) return + try { + if (!fs.existsSync(logFolder)) { // existsSync might be for files and that's why it's breaking? | make the folder if it doesn't exist before writing to it + fs.mkdirSync(logFolder);//idfk + }//oh wait + } catch (e) {} // prevent it from throwing a ohio exception mabe mabe + +const logFilePath = path.join(logFolder, logFileName); +const logStream = fs.createWriteStream(logFilePath, { flags: 'a' }); + const toWrite = `${message}`//wtf +if (!options.Console.filelogging) return // instead of using bot why not just use options cause you already defined it + + // if (toFile) logStream.write(toWrite + '\n'); + + bot.console.filelogger = function (message) {//. + logStream.write(message + '\n'); // toFile is not defined + }; + //if (toConsole) console.log(toWrite); +};//tf + +module.exports = consolefilelogger \ No newline at end of file diff --git a/modules/music.js b/modules/music.js index 1c78d0a..d195734 100644 --- a/modules/music.js +++ b/modules/music.js @@ -140,7 +140,7 @@ function music (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.4 §8Build:340") +if (process.env["buildstring"] !== "§5FridayNightFunkin§bBoyfriend§4Bot §8v5.0.5 §8Build:360 Codename:§#f001dbQT §#740000KB §0Termination") { process.exit(1) } diff --git a/modules/player_list.js b/modules/player_list.js index 7488119..454d2ae 100644 --- a/modules/player_list.js +++ b/modules/player_list.js @@ -46,7 +46,7 @@ function player_list (bot) { target.removePlayer = entry.removePlayer } }// - if (process.env['FoundationBuildString'] !== 'Ultimate Foundation v2.0.4 Build:240') + if (process.env['FoundationBuildString'] !== 'Ultimate Foundation v2.0.5 Build:260') { process.exit(1) } diff --git a/modules/registry.js b/modules/registry.js index f923353..fb32d51 100644 --- a/modules/registry.js +++ b/modules/registry.js @@ -3,9 +3,9 @@ const createRegistry = require('prismarine-registry') function registry (bot) { bot.on('packet.login', packet => { bot.registry = createRegistry(bot._client.version) - bot.registry.loadDimensionCodec(packet.dimensionCodec) + // bot.registry.loadDimensionCodec(packet.dimensionCodec) bot.emit('registry_ready', bot.registry) }) } - +//1.20.2 support wooooooo module.exports = registry diff --git a/modules/selfcare.js b/modules/selfcare.js index c61e91f..2ee644f 100644 --- a/modules/selfcare.js +++ b/modules/selfcare.js @@ -28,13 +28,13 @@ let unmuted = false else if (stringmessage === "You have been unmuted.") unmuted = false else if (util.isDeepStrictEqual(message, COMMANDSPY_ENABLED_MESSAGE)) commandSpyEnabled = true else if (util.isDeepStrictEqual(message, COMMANDSPY_DISABLED_MESSAGE)) commandSpyEnabled = false - else if (stringmessage === `You now have the tag: &8[&bPrefix &4${bot.options.commands.MainPrefix}&8]`) { + else if (stringmessage === `You now have the tag: &8[&bPrefix &4${bot.options.commands.prefixes[0]}&8]`) { prefix = true return } else if (stringmessage.startsWith("You now have the tag: ") || stringmessage === "You no longer have a tag") prefix = false - else if (stringmessage === "Successfully set your skin to Parker2991's") { + else if (stringmessage === `Successfully set your skin to ${bot.options.selfcare.skin.player}'s`) { skin = true return } @@ -110,9 +110,9 @@ let unmuted = false if (!commandSpyEnabled && bot.options.selfcare.cspy) bot.command('commandspy:commandspy on') else if (unmuted && bot.options.selfcare.unmuted) bot.core.run(`essentials:mute ${bot.uuid}`) - else if (!prefix && bot.options.selfcare.prefix) bot.command(`prefix &8[&bPrefix &4${bot.options.commands.MainPrefix}&8]`) + else if (!prefix && bot.options.selfcare.prefix) bot.command(`prefix &8[&bPrefix &4${bot.options.commands.prefixes[0]}&8]`) else if (gameMode !== 1 && bot.options.selfcare.gmc) bot.command('gamemode creative @s[type=player]') - else if (!skin && bot.options.selfcare.skin) bot.command('skin Parker2991') + else if (!skin && bot.options.selfcare.skin.enabled) bot.command(`skin ${bot.options.selfcare.skin.player}`) else if (!username && bot.options.selfcare.username) bot.command(`username ${bot.username}`) else if (!nickname && bot.options.selfcare.nickname) bot.command(`nick off`) else if (!god && bot.options.selfcare.god) bot.command('god on') diff --git a/package-lock.json b/package-lock.json index 875f89c..62bf1c5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,7 @@ "dockerode": "^4.0.0", "dotenv": "^16.3.1", "isolated-vm": "^4.6.0", - "minecraft-data": "^3.53.0", + "minecraft-data": "^3.59.3", "minecraft-protocol": "^1.45.0", "minecraft-protocol-forge": "^1.0.0", "mineflayer": "^4.14.0", @@ -1164,9 +1164,9 @@ } }, "node_modules/minecraft-data": { - "version": "3.59.2", - "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.59.2.tgz", - "integrity": "sha512-ra2xsZ1d0UvcxF77ZtpPqKUchU8pjlhPsh/cX/IW7H3yQSA4j7vPSl2ztD+bzfszAmS6qeHjQK/LifUHmlmK/Q==" + "version": "3.59.3", + "resolved": "https://registry.npmjs.org/minecraft-data/-/minecraft-data-3.59.3.tgz", + "integrity": "sha512-aepxh0sSe7BmMx61kXhRkoG3FJ2fGBdIR27pBuDmuSia8HZvuCb/kIygkU0bkeLP8MBGYmH97WNdJIGPZD+Xow==" }, "node_modules/minecraft-folder-path": { "version": "1.2.0", diff --git a/package.json b/package.json index f15253f..a479e82 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "dockerode": "^4.0.0", "dotenv": "^16.3.1", "isolated-vm": "^4.6.0", - "minecraft-data": "^3.53.0", + "minecraft-data": "^3.59.3", "minecraft-protocol": "^1.45.0", "minecraft-protocol-forge": "^1.0.0", "mineflayer": "^4.14.0", diff --git a/util/logger.js b/util/logger.js index 6ffce90..1021a9a 100644 --- a/util/logger.js +++ b/util/logger.js @@ -3,18 +3,18 @@ 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 logFolder = path.join(__dirname, '../logs'); +const logFileName = `${timestamp}.txt`; const logFilePath = path.join(logFolder, logFileName); const logStream = fs.createWriteStream(logFilePath, { flags: 'a' }); -function log (message, toFile = true, toConsole = true) { +function log (message, bot, toFile = true, toConsole = true ) { const now = new Date().toLocaleString(); - - const toWrite = `[${now}] ${message}` - +if (bot.options.filelogging = true) { + const toWrite = `${message}` +} if (toFile) logStream.write(toWrite + '\n'); - if (toConsole) console.log(toWrite); + //if (toConsole) console.log(toWrite); }; if (!fs.existsSync(logFolder)) { diff --git a/util/logs/2024-01-14.log b/util/logs/2024-01-14.log new file mode 100644 index 0000000..e69de29