diff --git a/package-lock.json b/package-lock.json index 082d8c1..387180f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,5 +1,5 @@ { - "name": "FNFBoyfriendBot-dev", + "name": "FNFBoyfriendBot v8", "lockfileVersion": 3, "requires": true, "packages": { diff --git a/src/bot.js b/src/bot.js index b5b774f..0ac5614 100644 --- a/src/bot.js +++ b/src/bot.js @@ -79,7 +79,7 @@ class Bot { }); process.on("uncaughtException", (e) => { - bot.console.warn(`${e.toString()}`); + bot.console.warn(`${e.stack}`); }); client.on("success", () => { diff --git a/src/chatparsers/creayun.js b/src/chat_parsers/creayun.js similarity index 100% rename from src/chatparsers/creayun.js rename to src/chat_parsers/creayun.js diff --git a/src/chatparsers/kaboom.js b/src/chat_parsers/kaboom.js similarity index 100% rename from src/chatparsers/kaboom.js rename to src/chat_parsers/kaboom.js diff --git a/src/chatparsers/vanilla.js b/src/chat_parsers/vanilla.js similarity index 100% rename from src/chatparsers/vanilla.js rename to src/chat_parsers/vanilla.js diff --git a/src/command_util/command_arguments.js b/src/command_util/command_arguments.js new file mode 100644 index 0000000..e69de29 diff --git a/src/command_util/command_source.js b/src/command_util/command_source.js index fd5f429..2d96e65 100644 --- a/src/command_util/command_source.js +++ b/src/command_util/command_source.js @@ -1,7 +1,8 @@ class CommandSource { - constructor(player, sources) { + constructor(player, sources, hash) { this.player = player; this.sources = sources; + this.hash = hash; } } module.exports = CommandSource; diff --git a/src/command_util/command_trust_level.js b/src/command_util/command_trust_level.js new file mode 100644 index 0000000..460c1af --- /dev/null +++ b/src/command_util/command_trust_level.js @@ -0,0 +1,10 @@ +class command_trust_level { + public = 0; + trusted = 1; + admin = 2; + owner = 3; + console = 4; + disabled = 5; +} + +module.exports = command_trust_level; \ No newline at end of file diff --git a/src/commands/admin/coreSettings.js b/src/commands.old/admin/coreSettings.js similarity index 100% rename from src/commands/admin/coreSettings.js rename to src/commands.old/admin/coreSettings.js diff --git a/src/commands.old/admin/kick.js b/src/commands.old/admin/kick.js new file mode 100644 index 0000000..b0cb6aa --- /dev/null +++ b/src/commands.old/admin/kick.js @@ -0,0 +1,37 @@ +const CommandError = require("../../command_util/command_error"); +const CommandContext = require("../../command_util/command_context"); + +class KickCommand extends CommandContext { + constructor() { + super("kick", [], "kick a player from the server", 2, [ + "invalidstring", + "item", + "te", + ]); + } + execute(context) { + const bot = context.bot; + const args = context.arguments; + const config = context.config; + + if (!args && !args[0] && !args[1] && !args[2]) return; + switch (args[1]?.toLowerCase()) { + case "invalidstring": + bot.exploits.crashes.invalidString(args[2]); + bot.tellraw("@a", `crashing ${args[2]}`); + break; + case "item": + bot.exploits.kicks.item(args[2]); + bot.tellraw("@a", `kicking ${args[2]}`); + break; + case "te": + bot.exploits.kicks.translateEntity(args[2]); + bot.tellraw("@a", `kicking ${args[2]}`); + break; + default: + throw new CommandError("invalid argument"); + } + } +} + +module.exports = KickCommand; diff --git a/src/commands/admin/reconnect.js b/src/commands.old/admin/reconnect.js similarity index 100% rename from src/commands/admin/reconnect.js rename to src/commands.old/admin/reconnect.js diff --git a/src/commands.old/console/console.js b/src/commands.old/console/console.js new file mode 100644 index 0000000..300a3b9 --- /dev/null +++ b/src/commands.old/console/console.js @@ -0,0 +1,118 @@ +const CommandContext = require("../../command_util/command_context"); +const CommandError = require('../../command_util/command_error') + +class ConsoleCommand extends CommandContext { + constructor() { + super("console", ["c"], "runs commands made for the bots console", 4, [ + "server/srv ", + "customchat ", + "say ", + "validate/validation/val ", + "logging/togglelogging/logtoconsole ", + ]); + } + execute(context) { + const bot = context.bot; + const args = context.arguments; + const source = context.source; + const config = context.config; + if (!args && !args[0] && !args[1] && !args[2] && !args[3]) return; + switch (args[0]?.toLowerCase()) { + case "server": + case "svr": + const servers = bot.bots.map((eachBot) => eachBot.options.serverName); + for (const eachBot of bot.bots) { + if (args.slice(1).join(" ").toLowerCase() === "all") { + eachBot.console.server = "all"; + bot.console.info("Set the console server to all"); + continue; + } + const server = servers.find((server) => + server.toLowerCase().includes(args[1]), + ); + if (!server) { + bot.console.info("Invalid server"); + return; + } + bot.console.info(`Set the console server to ` + server); + eachBot.console.server = server; + } + break; + case "say": + bot.chat.send(args.slice(1).join(" ")); + break; + case "validate": + case "validation": + case "val": + switch (args[1]?.toLowerCase()) { + case "owner": + case "o": + bot.chat.message( + `${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.owner} ${args.slice(3).join(" ")}`, + ); + break; + case "admin": + case "a": + bot.chat.message( + `${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.admin} ${args.slice(3).join(" ")}`, + ); + break; + case "trusted": + case "t": + bot.chat.message( + `${config.prefixes[0]}${args.slice(2).shift()} ${bot.validation.trusted} ${args.slice(3).join(" ")}`, + ); + break; + default: + throw new CommandError({ + translate: "command.unknown.argument", + color: "dark_red", + }); + } + break; + case "logging": + case "togglelogging": + case "logtoconsole": + switch (args[1]?.toLowerCase()) { + case "on": + case "enable": + case "enabled": + case "true": + if (bot.options.logging === true) { + bot.console.info( + `logging for ${bot.options.serverName} is already enabled!`, + ); + } else { + bot.console.info( + `logging for ${bot.options.serverName} is now enabled`, + ); + bot.options.logging = true; + } + break; + case "off": + case "disable": + case "disabled": + case "false": + if (bot.options.logging === false) { + bot.console.info( + `logging for ${bot.options.serverName} is already disabled!`, + ); + } else { + bot.console.info( + `logging for ${bot.options.serverName} is now disabled`, + ); + bot.options.logging = false; + } + break; + } + break; + default: + throw new CommandError({ + translate: "command.unknown.argument", + color: "dark_red", + }); + } + } +} + +module.exports = ConsoleCommand; diff --git a/src/commands.old/owner/kill.js b/src/commands.old/owner/kill.js new file mode 100644 index 0000000..19eeccf --- /dev/null +++ b/src/commands.old/owner/kill.js @@ -0,0 +1,12 @@ +const CommandContext = require("../../command_util/command_context"); + +class KillCommand extends CommandContext { + constructor() { + super("kill", ["suicide", "quit"], "kill the bots process", 3, [""]); + } + execute(context) { + const bot = context.bot; + process.exit(1); + } +} +module.exports = KillCommand; diff --git a/src/commands/owner/servereval.js b/src/commands.old/owner/servereval.js similarity index 100% rename from src/commands/owner/servereval.js rename to src/commands.old/owner/servereval.js diff --git a/src/commands.old/public/core.js b/src/commands.old/public/core.js new file mode 100644 index 0000000..a0a51ed --- /dev/null +++ b/src/commands.old/public/core.js @@ -0,0 +1,36 @@ +const sleep = require("../../util/sleep"); +const CommandContext = require("../../command_util/command_context"); + +class core extends CommandContext { + constructor() { + super("core", ["cb", "cbrun", "corerun"], "run commands in core", 0, [ + "$username ", + "$uuid ", + "", + ]); + } + execute(context) { + const bot = context.bot; + const args = context.arguments; + const source = context.source + + if (args.includes("$username") || args.includes("$uuid")) { + bot.players.forEach((eachPlayer) => { + bot.core.runTracked( + args + .join(" ") + .replaceAll("$username", eachPlayer.profile.name) + .replaceAll("$uuid", eachPlayer.uuid), + source + ); + // await sleep(1000) + }); + } else if (bot.options.mode === "savageFriends") { + bot.core.run(args.join(" ")); + } else { + bot.core.runTracked(args.join(" "), source); + } + } +} + +module.exports = core; diff --git a/src/commands.old/public/echo.js b/src/commands.old/public/echo.js new file mode 100644 index 0000000..5cd35a4 --- /dev/null +++ b/src/commands.old/public/echo.js @@ -0,0 +1,18 @@ +const CommandContext = require("../../command_util/command_context"); + +class EchoCommand extends CommandContext { + constructor() { + super("echo", ["say", "botsay"], "make me say something!", 0, [ + "", + ]); + } + + execute(context) { + const bot = context.bot; + const args = context.arguments; + + bot.chat.send(`${args.join(" ")}`); + } +} + +module.exports = EchoCommand; diff --git a/src/commands.old/public/help.js b/src/commands.old/public/help.js new file mode 100644 index 0000000..f406095 --- /dev/null +++ b/src/commands.old/public/help.js @@ -0,0 +1,446 @@ +const fixansi = require("../../util/ansi"); +const CommandContext = require("../../command_util/command_context"); + +class HelpCommand extends CommandContext { + constructor() { + super( + "help", + ["heko", "?", "cmds", "commands", "hell"], + "see a list of commands", + 0, + [""], + ); + } + + execute(context) { + const bot = context.bot; + const args = context.arguments; + const config = context.config; + const source = context.source; + + let component = []; + let infoComponent = []; + let usagesComponent = []; + let Public = []; + let trusted = []; + let admin = []; + let owner = []; + let Console = []; + + let cat = { + translate: "(%s | %s | %s | %s)", + color: config.colors.commands.tertiary, + with: [ + { text: "Public", color: config.colors.help.public }, + { text: "Trusted", color: config.colors.help.trusted }, + { text: "Admin", color: config.colors.help.admin }, + { text: "Owner", color: config.colors.help.owner }, + ], + }; + + component.push({ + translate: "%s: (%s) %s \u203a\n", + color: config.colors.commands.tertiary, + with: [ + { text: "Commands", color: config.colors.commands.secondary }, + { + text: `${bot.commandManager.commandlist.length}`, + color: config.colors.integer, + }, + cat, + ], + }); + for (const commands of bot.commandManager.commandlist) { + switch (commands.data.trustLevel) { + case 0: + Public.push({ + text: commands.data.name + " ", + color: config.colors.help.public, + translate: "", + hoverEvent: { + action: "show_text", + value: [ + { + translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s", + color: config.colors.commands.tertiary, + with: [ + { + text: "Command Name", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.name}`, + color: config.colors.commands.secondary, + }, + { + text: "Trust Level", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.trustLevel}`, + color: config.colors.integer, + }, + { + text: "Description", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.description}`, + color: config.colors.commands.secondary, + }, + { text: "Aliases", color: config.colors.commands.primary }, + { + text: `${commands.data.aliases}`, + color: config.colors.commands.secondary, + }, + { text: "Usages", color: config.colors.commands.primary }, + { + text: `${commands.data.usages}`, + color: config.colors.commands.secondary, + }, + ], + }, + ], + }, + clickEvent: { + action: "suggest_command", + value: `${config.prefixes[0]}${commands.data.name}`, + }, + }); + break; + case 1: + trusted.push({ + text: commands.data.name + " ", + color: config.colors.help.trusted, + translate: "", + hoverEvent: { + action: "show_text", + value: [ + { + translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s", + color: config.colors.commands.tertiary, + with: [ + { + text: "Command Name", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.name}`, + color: config.colors.commands.secondary, + }, + { + text: "Trust Level", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.trustLevel}`, + color: config.colors.integer, + }, + { + text: "Description", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.description}`, + color: config.colors.commands.secondary, + }, + { text: "Aliases", color: config.colors.commands.primary }, + { + text: `${commands.data.aliases}`, + color: config.colors.commands.secondary, + }, + { text: "Usages", color: config.colors.commands.primary }, + { + text: `${commands.data.usages}`, + color: config.colors.commands.secondary, + }, + ], + }, + ], + }, + clickEvent: { + action: "suggest_command", + value: `${config.prefixes[0]}${commands.data.name}`, + }, + }); + break; + case 2: + admin.push({ + text: commands.data.name + " ", + color: config.colors.help.admin, + translate: "", + hoverEvent: { + action: "show_text", + value: [ + { + translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s", + color: config.colors.commands.tertiary, + with: [ + { + text: "Command Name", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.name}`, + color: config.colors.commands.secondary, + }, + { + text: "Trust Level", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.trustLevel}`, + color: config.colors.integer, + }, + { + text: "Description", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.description}`, + color: config.colors.commands.secondary, + }, + { text: "Aliases", color: config.colors.commands.primary }, + { + text: `${commands.data.aliases}`, + color: config.colors.commands.secondary, + }, + { text: "Usages", color: config.colors.commands.primary }, + { + text: `${commands.data.usages}`, + color: config.colors.commands.secondary, + }, + ], + }, + ], + }, + clickEvent: { + action: "suggest_command", + value: `${config.prefixes[0]}${commands.data.name}`, + }, + }); + break; + case 3: + owner.push({ + text: commands.data.name + " ", + color: config.colors.help.owner, + translate: "", + hoverEvent: { + action: "show_text", + value: [ + { + translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s", + color: config.colors.commands.tertiary, + with: [ + { + text: "Command Name", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.name}`, + color: config.colors.commands.secondary, + }, + { + text: "Trust Level", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.trustLevel}`, + color: config.colors.integer, + }, + { + text: "Description", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.description}`, + color: config.colors.commands.secondary, + }, + { text: "Aliases", color: config.colors.commands.primary }, + { + text: `${commands.data.aliases}`, + color: config.colors.commands.secondary, + }, + { text: "Usages", color: config.colors.commands.primary }, + { + text: `${commands.data.usages}`, + color: config.colors.commands.secondary, + }, + ], + }, + ], + }, + clickEvent: { + action: "suggest_command", + value: `${config.prefixes[0]}${commands.data.name}`, + }, + }); + break; + case 4: + Console.push({ + text: commands.data.name + " ", + color: config.colors.help.console, + translate: "", + hoverEvent: { + action: "show_text", + value: [ + { + translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s", + color: config.colors.commands.tertiary, + with: [ + { + text: "Command Name", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.name}`, + color: config.colors.commands.secondary, + }, + { + text: "Trust Level", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.trustLevel}`, + color: config.colors.integer, + }, + { + text: "Description", + color: config.colors.commands.primary, + }, + { + text: `${commands.data.description}`, + color: config.colors.commands.secondary, + }, + { text: "Aliases", color: config.colors.commands.primary }, + { + text: `${commands.data.aliases}`, + color: config.colors.commands.secondary, + }, + { text: "Usages", color: config.colors.commands.primary }, + { + text: `${commands.data.usages}`, + color: config.colors.commands.secondary, + }, + ], + }, + ], + }, + clickEvent: { + action: "suggest_command", + value: `${config.prefixes[0]}${commands.data.name}`, + }, + }); + break; + default: + bot.chat.message( + `fuck you ${commands.data.name} has a invalid trust level`, + ); + } + + if ( + args[0]?.toLowerCase() === commands.data.name?.toLowerCase() || + commands.data.aliases.find( + (e) => e?.toLowerCase() === args[0]?.toLowerCase(), + ) + ) { + for (const usages of commands.data.usages) { + usagesComponent.push({ + translate: "%s%s %s", + with: [ + { + text: `${config.prefixes[0]}`, + color: config.colors.commands.primary, + }, + { + text: `${commands.data.name}`, + color: config.colors.commands.secondary, + }, + { text: `${usages}`, color: config.colors.commands.secondary }, + ], + }); + + usagesComponent.push("\n"); + } + + usagesComponent.pop(); + + infoComponent.push({ + translate: "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s:\n", + color: config.colors.commands.tertiary, + with: [ + { text: "Name", color: config.colors.commands.primary }, + { + text: `${commands.data.name}`, + color: config.colors.commands.secondary, + }, + { text: "Aliases", color: config.colors.commands.primary }, + { + text: `${commands.data.aliases.toString().replaceAll(",", " ")}`, + color: config.colors.commands.secondary, + }, + { text: "Description", color: config.colors.commands.primary }, + { + text: `${commands.data.description}`, + color: config.colors.commands.secondary, + }, + { text: "Trust Level", color: config.colors.commands.primary }, + { + text: `${commands.data.trustLevel}`, + color: config.colors.integer, + }, + { text: "Usages", color: config.colors.commands.primary }, + ], + }); + + infoComponent.push(usagesComponent); + + if (source?.sources.console) { + bot.console.info(bot.getMessageAsPrismarine(infoComponent)?.toAnsi()); + } else if (source.sources.discord) { + bot.discord.message.reply( + `\`\`\`ansi\n${fixansi(bot.getMessageAsPrismarine(infoComponent)?.toAnsi())}\`\`\``, + ); + } else { + bot.tellraw(`@a`, infoComponent); + } + return; + } + } + + if (Public.length > 0) { + component.push(Public); + if (trusted.length > 0) component.push("\n"); + } + + if (trusted.length > 0) { + component.push(trusted); + if (admin.length > 0) component.push("\n"); + } + + if (admin.length > 0) { + component.push(admin); + if (owner.length > 0) component.push("\n"); + } + + if (owner.length > 0) { + component.push(owner); + } + + if (source.sources.console && Console.length > 0) { + component.push(Console); + } + + if (source?.sources?.console) { + bot.console.info(bot.getMessageAsPrismarine(component)?.toAnsi()); + } else if (source.sources.discord) { + bot.discord.message.reply( + `\`\`\`ansi\n${fixansi(bot.getMessageAsPrismarine(component)?.toAnsi())}\`\`\``, + ); + } else { + bot.tellraw("@a", component); + } + } +} + +module.exports = HelpCommand; diff --git a/src/commands.old/public/info.js b/src/commands.old/public/info.js new file mode 100644 index 0000000..accf732 --- /dev/null +++ b/src/commands.old/public/info.js @@ -0,0 +1,605 @@ +const os = require("os"); +const CommandError = require("../../command_util/command_error"); +const fs = require("fs"); +const botInfo = require("../../data/info.json"); +const fixansi = require("../../util/ansi.js"); +const { execSync } = require("child_process"); +const CommandContext = require("../../command_util/command_context"); + +function format(seconds) { + function pad(s) { + return (s < 10 ? "0" : "") + s; + } + var hours = Math.floor(seconds / (60 * 60)); + var minutes = Math.floor((seconds % (60 * 60)) / 60); + var seconds = Math.floor(seconds % 60); + return ( + pad(`${hours} Hours`) + + " " + + pad(`${minutes} Minutes`) + + " " + + pad(`${seconds} Seconds`) + ); +} + +class InfoCommand extends CommandContext { + constructor() { + super("info", ["information"], "check the bots info", 0, [ + "about", + "config ", + "contributors/credits", + "discord", + "loaded", + "usages ", + "uptimes/uptime ", + "server", + "version/ver", + ]); + } + + execute(context) { + const bot = context.bot; + const args = context.arguments; + const config = context.config; + const discordClient = context.discordClient; + const source = context.source; + let component = []; + + switch (args[0]?.toLowerCase()) { + case "about": + component.push({ + text: `FNFBoyfriendBot is a kaboom bot created by Parker2991\nThe source code and changelog can be found here ${botInfo.buildstring.url}`, + color: `${config.colors.commands.primary}`, + translate: "", + hoverEvent: { + action: "show_text", + value: [ + { + text: "click here to view bots source code", + color: `${config.colors.commands.primary}`, + }, + ], + }, + clickEvent: { + action: "open_url", + value: `${botInfo.buildstring.url}`, + }, + }); + break; + case "config": + if (bot.options.isKaboom) { + mode = "Kaboom"; + } + if (bot.options.useChat && bot.options.isKaboom) { + mode = "Kaboom/Coreless"; + } + if (bot.options.isSavage) { + mode = "Savage"; + } + if (bot.options.isCreayun) { + mode = "Creayun"; + } + switch (args.slice(1).join(" ")?.toLowerCase()) { + case "client": + component.push({ + translate: "%s: %s:%s\n%s: %s\n%s: %s\n%s: %s", + color: config.colors.commands.tertiary, + with: [ + { text: "Server", color: config.colors.commands.primary }, + { + text: `${bot.options.host}`, + color: config.colors.commands.secondary, + }, + { text: `${bot.options.port}`, color: config.colors.integer }, + { text: "Server Name", color: config.colors.commands.primary }, + { + text: `${bot.options.serverName}`, + color: config.colors.commands.secondary, + }, + { + text: "Minecraft Username", + color: config.colors.commands.primary, + }, + { + text: `${bot.options.username}`, + color: config.colors.commands.secondary, + }, + { text: "Version", color: config.colors.commands.primary }, + { + text: `${bot.options.version}`, + color: config.colors.integer, + }, + ], + }); + break; + case "discord": + if (!config.discord.enabled || discordClient.user === null) { + throw new CommandError( + "Token is incorrect or discord isnt enabled!", + ); + } else { + component.push({ + translate: "%s: %s\n%s: %s", + color: config.colors.commands.tertiary, + with: [ + { + text: "Discord Username", + color: config.colors.commands.primary, + }, + { + text: `${discordClient.user.tag}`, + color: config.colors.commands.secondary, + }, + { + text: "Discord Channel", + color: config.colors.commands.primary, + }, + { + text: `${bot.discord?.channel?.name}`, + color: config.colors.commands.secondary, + }, + ], + }); + } + break; + case "options": + component.push({ + translate: "%s: %s\n%s: %s\n%s: %s", + color: config.colors.commands.tertiary, + with: [ + { text: "Server Count", color: config.colors.commands.primary }, + { text: `${bot.bots.length}`, color: config.colors.integer }, + { text: "Prefixes", color: config.colors.commands.primary }, + { + text: `${config.prefixes.map((e) => e + " ").join(" ")}`, + color: config.colors.commands.secondary, + }, + { text: "Mode", color: config.colors.commands.primary }, + { + text: `${bot.options.mode}`, + color: config.colors.commands.secondary, + }, + ], + }); + break; + case "all": + component.push({ + translate: + "%s: %s:%s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s", + color: config.colors.commands.tertiary, + with: [ + { text: "Server", color: config.colors.commands.primary }, + { + text: `${bot.options.host}`, + color: config.colors.commands.secondary, + }, + { text: `${bot.options.port}`, color: config.colors.integer }, + { text: "Server Name", color: config.colors.commands.primary }, + { + text: `${bot.options.serverName}`, + color: config.colors.commands.secondary, + }, + { + text: "Minecraft Username", + color: config.colors.commands.primary, + }, + { + text: `${bot.options.username}`, + color: config.colors.commands.secondary, + }, + { text: "Version", color: config.colors.commands.primary }, + { + text: `${bot.options.version}`, + color: config.colors.commands.secondary, + }, + { + text: "Discord Username", + color: config.colors.commands.primary, + }, + { + text: `${discordClient.user?.tag}`, + color: config.colors.commands.secondary, + }, + { + text: "Discord Channel", + color: config.colors.commands.primary, + }, + { + text: `${bot.discord.channel?.name}`, + color: config.colors.commands.secondary, + }, + { text: "Server Count", color: config.colors.commands.primary }, + { text: `${bot.bots.length}`, color: config.colors.integer }, + { text: "Prefixes", color: config.colors.commands.primary }, + { + text: `${config.prefixes.map((e) => e + " ").join(" ")}`, + color: config.colors.commands.secondary, + }, + { text: "Mode", color: config.colors.commands.primary }, + { + text: `${bot.options.mode}`, + color: config.colors.commands.secondary, + }, + ], + }); + break; + default: + throw new CommandError({ + translate: "command.unknown.argument", + color: "dark_red", + }); + } + break; + case "contributors": + case "credits": + component.push({ + translate: "%s%s - %s\n%s:\n%s\n%s\n%s\n%s\n%s %s\n%s\n%s", + color: config.colors.commands.tertiary, + with: [ + { text: "Parker", color: "dark_red" }, + { text: "2991", color: "black" }, + { text: "Owner" }, + { text: "Contributors" }, + { text: "_ChipMC_", color: "dark_blue" }, + { text: "chayapak", color: "yellow" }, + { text: "_yfd", color: "light_purple" }, + { text: "aaa", color: "gold" }, + { text: "Morgan", color: "green" }, + { text: "Ankan", color: "dark_green" }, + { text: "TurtleKid", color: "green" }, + { text: "Ploat/ImGloriz", color: "#cd8ccb" }, + ], + }); + break; + case "discord": + component.push({ + text: `the discord server invite is ${config.discord.invite}`, + color: config.colors.commands.primary, + translate: "", + hoverEvent: { + action: "show_text", + value: [ + { + text: "click here to join the discord server!", + color: config.colors.commands.secondary, + }, + ], + }, + clickEvent: { + action: "open_url", + value: `${config.discord.invite}`, + }, + }); + break; + case "loaded": + component.push({ + translate: "%s %s\n%s %s", + color: config.colors.commands.tertiary, + with: [ + { + text: `${bot.commandManager.commandlist.length}`, + color: config.colors.integer, + }, + { text: "Commands", color: config.colors.commands.primary }, + { text: `${bot.modules.length}`, color: config.colors.integer }, + { text: "Modules", color: config.colors.commands.primary }, + ], + }); + break; + case "usages": + case "usage": + switch (args.slice(1).join(" ")?.toLowerCase()) { + case "bot": + component.push({ + translate: "%s: %s %s / %s %s", + color: config.colors.commands.tertiary, + with: [ + { + text: "Bot Memory", + color: config.colors.commands.primary, + }, + { + text: `${Math.floor(process.memoryUsage().heapUsed / 1048576)}`, + color: config.colors.integer, + }, + { text: "MiB", color: config.colors.commands.secondary }, + { + text: `${Math.floor(process.memoryUsage().heapTotal / 1048576)}`, + color: config.colors.integer, + }, + { text: "MiB", color: config.colors.commands.secondary }, + ], + }); + break; + case "server": + component.push({ + translate: "%s: %s %s / %s %s", + color: config.colors.commands.tertiary, + with: [ + { + text: "Server Memory", + color: config.colors.commands.primary, + }, + { + text: `${(Math.floor(os.totalmem() / 1048576) - Math.floor(os.freemem() / 1048576))}`, + color: config.colors.integer, + }, + { text: "MB", color: config.colors.commands.secondary }, + { + text: `${Math.floor(os.totalmem() / 1048576)}`, + color: config.colors.integer, + }, + { text: "MB", color: config.colors.commands.secondary }, + ], + }); + break; + case "all": + component.push({ + translate: "%s: %s %s / %s %s\n%s: %s %s / %s %s", + color: config.colors.commands.tertiary, + with: [ + { + text: "Server Memory", + color: config.colors.commands.primary, + }, + { + text: `${(Math.floor(os.totalmem() / 1048576) - Math.floor(os.freemem() / 1048576))}`, + color: config.colors.integer, + }, + { text: "MB", color: config.colors.commands.secondary }, + { + text: `${Math.floor(os.totalmem() / 1048576)}`, + color: config.colors.integer, + }, + { text: "MB", color: config.colors.commands.secondary }, + { + text: "Bot Memory", + color: config.colors.commands.primary, + }, + { + text: `${Math.floor(process.memoryUsage().heapUsed / 1048576)}`, + color: config.colors.integer, + }, + { text: "MB", color: config.colors.commands.secondary }, + { + text: `${Math.floor(process.memoryUsage().heapTotal / 1048576)}`, + color: config.colors.integer, + }, + { text: "MB", color: config.colors.commands.secondary }, + ], + }); + break; + default: + throw new CommandError({ + translate: "command.unknown.argument", + color: "dark_red", + }); + } + break; + case "uptimes": + switch (args.slice(1).join(" ")?.toLowerCase()) { + case "bot": + component.push({ + translate: "%s: %s", + color: config.colors.commands.tertiary, + with: [ + { text: "Bot Uptime", color: config.colors.commands.primary }, + { + text: `${format(process.uptime())}`, + color: config.colors.commands.secondary, + }, + ], + }); + break; + case "server": + component.push({ + translate: "%s: %s", + color: config.colors.commands.tertiary, + with: [ + { + text: "Server Uptime", + color: config.colors.commands.primary, + }, + { + text: `${format(os.uptime())}`, + color: config.colors.commands.secondary, + }, + ], + }); + break; + case "all": + component.push({ + translate: "%s: %s\n%s: %s", + color: config.colors.commands.tertiary, + with: [ + { text: "Bot Uptime", color: config.colors.commands.primary }, + { + text: `${format(process.uptime())}`, + color: config.colors.commands.secondary, + }, + { + text: "Server Uptime", + color: config.colors.commands.primary, + }, + { + text: `${format(os.uptime())}`, + color: config.colors.commands.secondary, + }, + ], + }); + break; + throw new CommandError({ + translate: "command.unknown.argument", + color: "dark_red", + }); + } + break; + case "server": + component.push({ + translate: + "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s", + color: config.colors.commands.tertiary, + with: [ + { text: "Hostname", color: config.colors.commands.primary }, + { + text: `${os.hostname()}`, + color: config.colors.commands.secondary, + }, + { text: "User", color: config.colors.commands.primary }, + { + text: `${os.userInfo().username}`, + color: config.colors.commands.secondary, + }, + { + text: "Working Directory", + color: config.colors.commands.primary, + }, + { + text: `${require.main.path}`, + color: config.colors.commands.secondary, + }, + { text: "Arch", color: config.colors.commands.primary }, + { text: `${os.arch()}`, color: config.colors.commands.secondary }, + { text: "OS", color: config.colors.commands.primary }, + { text: `${os.platform}`, color: config.colors.commands.secondary }, + { text: "OS Version", color: config.colors.commands.primary }, + { + text: `${os.version()}`, + color: config.colors.commands.secondary, + }, + { text: "Kernel Version", color: config.colors.commands.primary }, + { + text: `${os.release()}`, + color: config.colors.commands.secondary, + }, + { text: "CPU", color: config.colors.commands.primary }, + { + text: `${os.cpus()[0].model}`, + color: config.colors.commands.secondary, + }, + { text: "CPU cores", color: config.colors.commands.primary }, + { text: `${os.cpus().length}`, color: config.colors.integer }, + { text: "Processes", color: config.colors.commands.primary }, + { text: `${execSync("ps aux | wc -l").toString().replace('\n','')}`, color: config.colors.integer }, + { text: "Node Version", color: config.colors.commands.primary }, + { + text: `${process.version}`, + color: config.colors.commands.secondary, + }, + { text: "NPM Version", color: config.colors.commands.primary }, + { + text: `${execSync("npm -v").toString().replaceAll("\n", "")}`, + color: config.colors.commands.secondary, + }, + ], + }); + break; + case "version": + case "ver": + if (botInfo.buildstring.codename.length > 0) { + component.push({ + translate: "%s %s %s-%s-%s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s-%s", + color: config.colors.commands.tertiary, + with: [ + { text: "Friday Night Funkin", color: "dark_blue" }, + { text: "Boyfriend", color: "dark_aqua" }, + { text: "Bot", color: "blue" }, + { + text: `${botInfo.buildstring.version}`, + color: config.colors.integer, + }, + botInfo.buildstring.codename, + { text: "Build", color: config.colors.commands.primary }, + { + text: `${botInfo.buildstring.build}`, + color: config.colors.integer, + }, + { text: "Repo Build", color: config.colors.commands.primary }, + { + text: `${execSync("git rev-list --count --all").toString().replaceAll("\n", "")}`, + color: config.colors.integer, + }, + { + text: "Version Release Date", + color: config.colors.commands.primary, + }, + { + text: `${new Date(execSync("git log -1 --format=%ci").toString()).toLocaleString("en-US", { timeZone: "America/CHICAGO" })}`, + color: config.colors.commands.secondary, + }, + { text: "Commit", color: config.colors.commands.primary }, + { + text: `${execSync("git rev-parse HEAD").toString().substring(0, 10)}`, + color: config.colors.commands.secondary, + }, + { text: "11/22/22", color: config.colors.commands.primary }, + { + text: `${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`, + color: config.colors.commands.secondary, + }, + ], + }); + } else { + component.push({ + translate: "%s %s %s-%s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s-%s", + color: config.colors.commands.tertiary, + with: [ + { text: "Friday Night Funkin", color: "dark_blue" }, + { text: "Boyfriend", color: "dark_aqua" }, + { text: "Bot", color: "blue" }, + { + text: `${botInfo.buildstring.version}`, + color: config.colors.integer, + }, + { text: "Build", color: config.colors.commands.primary }, + { + text: `${botInfo.buildstring.build}`, + color: config.colors.integer, + }, + { text: "Repo Build", color: config.colors.commands.primary }, + { + text: `${execSync("git rev-list --count --all").toString().replaceAll("\n", "")}`, + color: config.colors.integer, + }, + { + text: "Version Release Date", + color: config.colors.commands.primary, + }, + { + text: `${new Date(execSync("git log -1 --format=%ci").toString()).toLocaleString("en-US", { timeZone: "America/CHICAGO" })}`, + color: config.colors.commands.secondary, + }, + { text: "Commit", color: config.colors.commands.primary }, + { + text: `${execSync("git rev-parse HEAD").toString().substring(0, 10)}`, + color: config.colors.commands.secondary, + }, + { text: "11/22/22", color: config.colors.commands.primary }, + { + text: `${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })}`, + color: config.colors.commands.secondary, + }, + ], + }); + } + break; + default: + throw new CommandError({ + translate: "command.unknown.argument", + color: "dark_red", + }); + } + + if (source?.sources?.console) { + bot.console.info(bot.getMessageAsPrismarine(component)?.toAnsi()); + } else if (source.sources.discord) { + bot.discord.message.reply( + `\`\`\`ansi\n${fixansi(bot.getMessageAsPrismarine(component)?.toAnsi())}\`\`\``, + ); + } else { + bot.tellraw("@a", component); + } + } +} + +module.exports = InfoCommand; diff --git a/src/commands/public/list.js b/src/commands.old/public/list.js similarity index 100% rename from src/commands/public/list.js rename to src/commands.old/public/list.js diff --git a/src/commands/public/mcserver.js b/src/commands.old/public/mcserver.js similarity index 100% rename from src/commands/public/mcserver.js rename to src/commands.old/public/mcserver.js diff --git a/src/commands/public/netmsg.js b/src/commands.old/public/netmsg.js similarity index 100% rename from src/commands/public/netmsg.js rename to src/commands.old/public/netmsg.js diff --git a/src/commands/public/refillcore.js b/src/commands.old/public/refillcore.js similarity index 100% rename from src/commands/public/refillcore.js rename to src/commands.old/public/refillcore.js diff --git a/src/commands/public/urban.js b/src/commands.old/public/urban.js similarity index 75% rename from src/commands/public/urban.js rename to src/commands.old/public/urban.js index 24f30cb..1975553 100644 --- a/src/commands/public/urban.js +++ b/src/commands.old/public/urban.js @@ -1,6 +1,10 @@ const CommandError = require("../../command_util/command_error"); const { request } = require("undici"); const CommandContext = require("../../command_util/command_context"); +const fixansi = require("../../util/ansi"); +const fs = require('fs') +const path = require('path') +const { AttachmentBuilder } = require('discord.js') class UrbanCommand extends CommandContext { constructor() { @@ -79,6 +83,31 @@ class UrbanCommand extends CommandContext { if (source.sources.console) { bot.console.info(bot.getMessageAsPrismarine(component)?.toAnsi()); + } else if (source.sources.discord) { + + const discordOutput = fixansi(bot.getMessageAsPrismarine(component)?.toAnsi()) + + if (discordOutput.length > 2000) { + const output = fs.writeFileSync(path.join(__dirname, '../../output.txt'), JSON.stringify(bot.getMessageAsPrismarine(component)?.toString())) + + const file = new AttachmentBuilder(path.join(__dirname, '../../output.txt')) + + bot.discord.message.reply('output', { + files: [file] + }) +// bot.discord.message.reply('meow') //[{ +// files: path.join(__dirname, '../../output.txt') + // }]) + + + +// fs.unlinkSync(path.join(__dirname, '../../output.txt')) + } else { + bot.discord.message.reply( + `\`\`\`ansi\n${discordOutput}\`\`\``, + ); + } +// console.log(discordOutput.length) } else if (bot.options.mode === "savageFriends") { bot.core.run(`minecraft:tellraw @a ${JSON.stringify(component)}`); } else { diff --git a/src/commands/public/weather.js b/src/commands.old/public/weather.js similarity index 100% rename from src/commands/public/weather.js rename to src/commands.old/public/weather.js diff --git a/src/commands/public/wiki.js b/src/commands.old/public/wiki.js similarity index 100% rename from src/commands/public/wiki.js rename to src/commands.old/public/wiki.js diff --git a/src/commands/trusted/cloop.js b/src/commands.old/trusted/cloop.js similarity index 100% rename from src/commands/trusted/cloop.js rename to src/commands.old/trusted/cloop.js diff --git a/src/commands.old/trusted/validate.js b/src/commands.old/trusted/validate.js new file mode 100644 index 0000000..bbee078 --- /dev/null +++ b/src/commands.old/trusted/validate.js @@ -0,0 +1,24 @@ +const CommandContext = require("../../command_util/command_context"); + +class ValidateCommand extends CommandContext { + constructor() { + super("validate", ["val"], "validate through the bot", 1, [""]); + } + execute(context) { + const bot = context.bot; + const args = context.arguments; + const source = context.source; + + if (args[0] === bot.validation.trusted) { + bot.chat.message("&2Valid Trusted hash"); + } + if (args[0] === bot.validation.admin) { + bot.chat.message("&2Valid Admin hash"); + } + if (args[0] === bot.validation.owner) { + bot.chat.message("&2Valid Owner hash"); + } + } +} + +module.exports = ValidateCommand; diff --git a/src/commands/admin/kick.js b/src/commands/admin/kick.js index b0cb6aa..152cd4d 100644 --- a/src/commands/admin/kick.js +++ b/src/commands/admin/kick.js @@ -1,7 +1,7 @@ const CommandError = require("../../command_util/command_error"); const CommandContext = require("../../command_util/command_context"); -class KickCommand extends CommandContext { +class kick extends CommandContext { constructor() { super("kick", [], "kick a player from the server", 2, [ "invalidstring", @@ -34,4 +34,4 @@ class KickCommand extends CommandContext { } } -module.exports = KickCommand; +module.exports = kick; diff --git a/src/commands/console/console.js b/src/commands/console/console.js index 300a3b9..b018dab 100644 --- a/src/commands/console/console.js +++ b/src/commands/console/console.js @@ -1,7 +1,7 @@ const CommandContext = require("../../command_util/command_context"); const CommandError = require('../../command_util/command_error') -class ConsoleCommand extends CommandContext { +class console extends CommandContext { constructor() { super("console", ["c"], "runs commands made for the bots console", 4, [ "server/srv ", @@ -115,4 +115,4 @@ class ConsoleCommand extends CommandContext { } } -module.exports = ConsoleCommand; +module.exports = console; diff --git a/src/commands/owner/kill.js b/src/commands/owner/kill.js index 19eeccf..408285b 100644 --- a/src/commands/owner/kill.js +++ b/src/commands/owner/kill.js @@ -1,6 +1,6 @@ const CommandContext = require("../../command_util/command_context"); -class KillCommand extends CommandContext { +class kill extends CommandContext { constructor() { super("kill", ["suicide", "quit"], "kill the bots process", 3, [""]); } @@ -9,4 +9,4 @@ class KillCommand extends CommandContext { process.exit(1); } } -module.exports = KillCommand; +module.exports = kill; diff --git a/src/commands/public/core.js b/src/commands/public/core.js index fbd175e..9b19187 100644 --- a/src/commands/public/core.js +++ b/src/commands/public/core.js @@ -1,13 +1,24 @@ const sleep = require("../../util/sleep"); const CommandContext = require("../../command_util/command_context"); +const CommandTrustLevel = require('../../command_util/command_trust_level') +const trustLevel = new CommandTrustLevel() -class CoreCommand extends CommandContext { +class core extends CommandContext { constructor() { - super("core", ["cb", "cbrun", "corerun"], "run commands in core", 0, [ - "$username ", - "$uuid ", - "", - ]); + super("core", + [ + "cb", + "cbrun", + "corerun" + ], + "run commands in core", + trustLevel.public, + [ + "$username ", + "$uuid ", + "", + ] + ); } execute(context) { const bot = context.bot; @@ -33,4 +44,4 @@ class CoreCommand extends CommandContext { } } -module.exports = CoreCommand; +module.exports = core; diff --git a/src/commands/public/echo.js b/src/commands/public/echo.js index 5cd35a4..0f28efa 100644 --- a/src/commands/public/echo.js +++ b/src/commands/public/echo.js @@ -1,8 +1,10 @@ const CommandContext = require("../../command_util/command_context"); +const CommandTrustLevel = require('../../command_util/command_trust_level') +const trustLevel = new CommandTrustLevel() -class EchoCommand extends CommandContext { +class echo extends CommandContext { constructor() { - super("echo", ["say", "botsay"], "make me say something!", 0, [ + super("echo", ["say", "botsay"], "make me say something!", trustLevel.public, [ "", ]); } @@ -15,4 +17,4 @@ class EchoCommand extends CommandContext { } } -module.exports = EchoCommand; +module.exports = echo; diff --git a/src/commands/public/help.js b/src/commands/public/help.js index f406095..3934232 100644 --- a/src/commands/public/help.js +++ b/src/commands/public/help.js @@ -1,13 +1,15 @@ const fixansi = require("../../util/ansi"); const CommandContext = require("../../command_util/command_context"); +const CommandTrustLevel = require('../../command_util/command_trust_level') +const trustLevel = new CommandTrustLevel() -class HelpCommand extends CommandContext { +class help extends CommandContext { constructor() { super( "help", ["heko", "?", "cmds", "commands", "hell"], "see a list of commands", - 0, + trustLevel.public, [""], ); } @@ -333,9 +335,9 @@ class HelpCommand extends CommandContext { }); break; default: - bot.chat.message( +/* bot.chat.message( `fuck you ${commands.data.name} has a invalid trust level`, - ); + );*/ } if ( @@ -443,4 +445,4 @@ class HelpCommand extends CommandContext { } } -module.exports = HelpCommand; +module.exports = help; diff --git a/src/commands/public/info.js b/src/commands/public/info.js index 16dcf6a..a916636 100644 --- a/src/commands/public/info.js +++ b/src/commands/public/info.js @@ -5,6 +5,8 @@ const botInfo = require("../../data/info.json"); const fixansi = require("../../util/ansi.js"); const { execSync } = require("child_process"); const CommandContext = require("../../command_util/command_context"); +const CommandTrustLevel = require('../../command_util/command_trust_level') +const trustLevel = new CommandTrustLevel() function format(seconds) { function pad(s) { @@ -22,9 +24,9 @@ function format(seconds) { ); } -class InfoCommand extends CommandContext { +class info extends CommandContext { constructor() { - super("info", ["information"], "check the bots info", 0, [ + super("info", ["information"], "check the bots info", trustLevel.public, [ "about", "config ", "contributors/credits", @@ -295,7 +297,7 @@ class InfoCommand extends CommandContext { color: config.colors.commands.tertiary, with: [ { - text: "Bot Memory Usage", + text: "Bot Memory", color: config.colors.commands.primary, }, { @@ -317,19 +319,19 @@ class InfoCommand extends CommandContext { color: config.colors.commands.tertiary, with: [ { - text: "Free Server Memory", + text: "Server Memory", color: config.colors.commands.primary, }, { - text: `${Math.floor(os.freemem() / 1048576)}`, + text: `${(Math.floor(os.totalmem() / 1048576) - Math.floor(os.freemem() / 1048576))}`, color: config.colors.integer, }, - { text: "MiB", color: config.colors.commands.secondary }, + { text: "MB", color: config.colors.commands.secondary }, { text: `${Math.floor(os.totalmem() / 1048576)}`, color: config.colors.integer, }, - { text: "MiB", color: config.colors.commands.secondary }, + { text: "MB", color: config.colors.commands.secondary }, ], }); break; @@ -339,33 +341,33 @@ class InfoCommand extends CommandContext { color: config.colors.commands.tertiary, with: [ { - text: "Free Server Memory", + text: "Server Memory", color: config.colors.commands.primary, }, { - text: `${Math.floor(os.freemem() / 1048576)}`, + text: `${(Math.floor(os.totalmem() / 1048576) - Math.floor(os.freemem() / 1048576))}`, color: config.colors.integer, }, - { text: "MiB", color: config.colors.commands.secondary }, + { text: "MB", color: config.colors.commands.secondary }, { text: `${Math.floor(os.totalmem() / 1048576)}`, color: config.colors.integer, }, - { text: "MiB", color: config.colors.commands.secondary }, + { text: "MB", color: config.colors.commands.secondary }, { - text: "Bot Memory Usage", + text: "Bot Memory", color: config.colors.commands.primary, }, { text: `${Math.floor(process.memoryUsage().heapUsed / 1048576)}`, color: config.colors.integer, }, - { text: "MiB", color: config.colors.commands.secondary }, + { text: "MB", color: config.colors.commands.secondary }, { text: `${Math.floor(process.memoryUsage().heapTotal / 1048576)}`, color: config.colors.integer, }, - { text: "MiB", color: config.colors.commands.secondary }, + { text: "MB", color: config.colors.commands.secondary }, ], }); break; @@ -437,7 +439,7 @@ class InfoCommand extends CommandContext { case "server": component.push({ translate: - "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s", + "%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s\n%s: %s", color: config.colors.commands.tertiary, with: [ { text: "Hostname", color: config.colors.commands.primary }, @@ -479,6 +481,8 @@ class InfoCommand extends CommandContext { }, { text: "CPU cores", color: config.colors.commands.primary }, { text: `${os.cpus().length}`, color: config.colors.integer }, + { text: "Processes", color: config.colors.commands.primary }, + { text: `${execSync("ps aux | wc -l").toString().replace('\n','')}`, color: config.colors.integer }, { text: "Node Version", color: config.colors.commands.primary }, { text: `${process.version}`, @@ -600,4 +604,4 @@ class InfoCommand extends CommandContext { } } -module.exports = InfoCommand; +module.exports = info; diff --git a/src/commands/trusted/validate.js b/src/commands/trusted/validate.js index bbee078..f3103cc 100644 --- a/src/commands/trusted/validate.js +++ b/src/commands/trusted/validate.js @@ -1,6 +1,6 @@ const CommandContext = require("../../command_util/command_context"); -class ValidateCommand extends CommandContext { +class validate extends CommandContext { constructor() { super("validate", ["val"], "validate through the bot", 1, [""]); } @@ -21,4 +21,4 @@ class ValidateCommand extends CommandContext { } } -module.exports = ValidateCommand; +module.exports = validate diff --git a/src/help-layout.txt b/src/help-layout.txt new file mode 100644 index 0000000..031461e --- /dev/null +++ b/src/help-layout.txt @@ -0,0 +1,5 @@ +Commands (19) (Public | Trusted | Admin | Owner) \u203a +~core ~echo ~help ~info ~list ~mcserver ~netmsg ~refillcore ~urban ~weather ~wiki +~cloop ~validate +~kick ~coresettings ~reconnect +~kill diff --git a/src/modules/boot.js b/src/modules/boot.js new file mode 100644 index 0000000..7c8585f --- /dev/null +++ b/src/modules/boot.js @@ -0,0 +1,7 @@ +class boot { + constructor () { + + } +} + +module.exports = boot; \ No newline at end of file diff --git a/src/modules/chat.js b/src/modules/chat.js index 30802ca..49b2be6 100644 --- a/src/modules/chat.js +++ b/src/modules/chat.js @@ -1,6 +1,6 @@ const loadPrismarineChat = require("prismarine-chat"); -const KaboomChatParser = require("../chatparsers/kaboom"); -const CreayunChatParser = require("../chatparsers/creayun"); +const KaboomChatParser = require("../chat_parsers/kaboom"); +const CreayunChatParser = require("../chat_parsers/creayun"); const convertNbtComponentToJson = require("../util/nbt_parser"); function tryParse(json) { @@ -11,7 +11,7 @@ function tryParse(json) { } } -class ChatModule { +class chat { constructor(context) { const bot = context.bot; const config = context.config; @@ -322,4 +322,4 @@ class ChatModule { }; } } -module.exports = ChatModule; +module.exports = chat; diff --git a/src/modules/command_core.js b/src/modules/command_core.js index f21f86a..cfe8e3b 100644 --- a/src/modules/command_core.js +++ b/src/modules/command_core.js @@ -3,7 +3,7 @@ const sleep = require("../util/sleep"); const convertNbtComponentToJson = require("../util/nbt_parser"); const fixansi = require("../util/ansi") -class CommandCoreModule { +class command_core { constructor(context) { const bot = context.bot; const config = context.config; @@ -259,4 +259,4 @@ class CommandCoreModule { }); } } -module.exports = CommandCoreModule; +module.exports = command_core; diff --git a/src/modules/command_handler.js b/src/modules/command_handler.js index bc6f0af..66fd767 100644 --- a/src/modules/command_handler.js +++ b/src/modules/command_handler.js @@ -1,6 +1,6 @@ const CommandSource = require("../command_util/command_source"); -class CommandHandlerModule { +class command_handler { constructor(context) { let ratelimit = 0; const bot = context.bot; @@ -9,7 +9,6 @@ class CommandHandlerModule { bot.on("parsed_message", (data) => { try { - // console.log(data.contents) if (data.type !== "minecraft:chat") return; const prefixes = config.prefixes; prefixes.map((prefix) => { @@ -44,4 +43,4 @@ class CommandHandlerModule { }); } } -module.exports = CommandHandlerModule; +module.exports = command_handler; diff --git a/src/modules/command_loop.js b/src/modules/command_loop.js index 4f8588f..4c78f5f 100644 --- a/src/modules/command_loop.js +++ b/src/modules/command_loop.js @@ -1,4 +1,4 @@ -class CommandLoopModule { +class command_loop { constructor(context) { const bot = context.bot; bot.cloop = { @@ -39,4 +39,4 @@ class CommandLoopModule { }; } } -module.exports = CommandLoopModule; +module.exports = command_loop; diff --git a/src/modules/command_manager.js b/src/modules/command_manager.js index af475ac..14f8a4e 100644 --- a/src/modules/command_manager.js +++ b/src/modules/command_manager.js @@ -5,7 +5,7 @@ const CommandSource = require("../command_util/command_source"); const fixansi = require("../util/ansi"); const sleep = require("../util/sleep.js"); -class CommandManagerModule { +class command_manager { constructor(context) { const bot = context.bot; const config = context.config; @@ -49,6 +49,8 @@ class CommandManagerModule { const event = bot.discord.message; const roles = event?.member?.roles?.cache; + + console.log(command) switch (command?.data?.trustLevel) { case 0: // do nothing since trust level 0 is public @@ -148,6 +150,9 @@ class CommandManagerModule { }); } break; + case 5: + throw new CommandError({ text: 'This Command has been disabled!', color: 'red' }) + break } if (source.sources.discord) { @@ -251,4 +256,4 @@ class CommandManagerModule { } } } -module.exports = CommandManagerModule; +module.exports = command_manager; diff --git a/src/modules/console.js b/src/modules/console.js index f50c21c..8bab657 100644 --- a/src/modules/console.js +++ b/src/modules/console.js @@ -1,7 +1,7 @@ const CommandSource = require("../command_util/command_source"); const prismarineChat = require("prismarine-chat")("1.20.2"); -class ConsoleModule { +class Console { // named it Console so that it doesnt override the console variable constructor(context) { const bot = context.bot; const config = context.config; @@ -116,4 +116,4 @@ class ConsoleModule { }); } } -module.exports = ConsoleModule; +module.exports = Console; diff --git a/src/modules/discord.js b/src/modules/discord.js index a18bc33..dc709af 100644 --- a/src/modules/discord.js +++ b/src/modules/discord.js @@ -1,7 +1,7 @@ const fixansi = require("../util/ansi"); const CommandSource = require("../command_util/command_source"); -class DiscordModule { +class discord { constructor(context) { const bot = context.bot; const config = context.config; @@ -199,4 +199,4 @@ class DiscordModule { discordClient.on("messageCreate", messageCreate); } } -module.exports = DiscordModule; +module.exports = discord; diff --git a/src/modules/fileLogger.js b/src/modules/file_logger.js similarity index 97% rename from src/modules/fileLogger.js rename to src/modules/file_logger.js index 633ad48..226d8d5 100644 --- a/src/modules/fileLogger.js +++ b/src/modules/file_logger.js @@ -4,7 +4,7 @@ const { createGzip } = require("zlib"); const readline = require("readline"); const { Console } = require("console"); -class FileloggerModule { +class file_logger { constructor(context) { const bot = context.bot; const config = context.config; @@ -71,4 +71,4 @@ class FileloggerModule { }; } } -module.exports = FileloggerModule; +module.exports = file_logger; diff --git a/src/modules/player_list.js b/src/modules/player_list.js index 6459bbc..40128c0 100644 --- a/src/modules/player_list.js +++ b/src/modules/player_list.js @@ -1,6 +1,6 @@ const convertNbtComponentToJson = require("../util/nbt_parser"); -class PlayerListModule { +class player_list { constructor(context) { const bot = context.bot; const config = context.config; @@ -109,4 +109,4 @@ class PlayerListModule { bot.on("end", () => (bot.players = [])); } } -module.exports = PlayerListModule; +module.exports = player_list; diff --git a/src/modules/position.js b/src/modules/position.js index c7b23bb..2627320 100644 --- a/src/modules/position.js +++ b/src/modules/position.js @@ -1,4 +1,4 @@ -class PositionModule { +class position { constructor(context) { const bot = context.bot; const config = context.config; @@ -21,4 +21,4 @@ class PositionModule { }); } } -module.exports = PositionModule; +module.exports = position; diff --git a/src/modules/reconnect.js b/src/modules/reconnect.js index 4c2e613..54411fb 100644 --- a/src/modules/reconnect.js +++ b/src/modules/reconnect.js @@ -1,6 +1,6 @@ const mc = require("minecraft-protocol"); const usernameGen = require("../util/usernameGen"); -class ReconnectModule { +class reconnect { constructor(context) { const bot = context.bot; const config = context.config; @@ -24,4 +24,4 @@ class ReconnectModule { }); } } -module.exports = ReconnectModule; +module.exports = reconnect; diff --git a/src/modules/registry.js b/src/modules/registry.js index 7e0b34e..7566c2b 100644 --- a/src/modules/registry.js +++ b/src/modules/registry.js @@ -1,6 +1,6 @@ const createRegistry = require("prismarine-registry"); -class RegistryModule { +class registry { constructor(context) { const bot = context.bot; bot.on("packet.login", (packet) => { @@ -10,4 +10,4 @@ class RegistryModule { }); } } -module.exports = RegistryModule; +module.exports = registry; diff --git a/src/modules/selfcare.js b/src/modules/selfcare.js index 4059309..757204d 100644 --- a/src/modules/selfcare.js +++ b/src/modules/selfcare.js @@ -1,255 +1,77 @@ -const sleep = require("../util/sleep"); +const fs = require('fs') +const path = require('path') -class SelfcareModule { - constructor(context) { - const bot = context.bot; - const config = context.config; - const options = context.options; - let clientLock; - let entityId; - let permissionLevel = 2; - let unmuted = false; - let gameMode; - let commandSpy = false; - let vanished = false; - let prefix = false; - let god = false; - let teleportToggle = false; - let username = false; - let nickname = false; - let login = false; - let register = false; - let positionCount = 0; - let loggedin = false - bot.vanished = true; - bot.on("message", (data) => { +class selfcare { + constructor (context) { + const bot = context.bot + const config = context.config + const options = context.options + let messageSelfcare + let loadMessageSelfcare + + bot.selfcare = { + permissionLevel: 2, + entityId: undefined, + gameMode: undefined, + commandSpy: undefined + } + + for (const file of fs.readdirSync(path.join(__dirname, '../selfcare/message'))) { try { - const stringMessage = bot.getMessageAsPrismarine(data)?.toString(); - if (options.mode === "savageFriends") { - if ( - stringMessage === - "Please, login with the command: /login " - ) - login = true; - else if (stringMessage === "Successful login!") login = false; - else if (stringMessage === "You're already logged in!") login = false; - else if ( - stringMessage === - "Please, register to the server with the command: /register " - ) - register = true; - else if (stringMessage === "This user isn't registered!") - register = true; - else if (stringMessage === "Successfully registered!") - register = false; - else if (stringMessage === "You're already logged in!") - register = false; - else if (stringMessage === "Successful login!") register = false; - else if ( - stringMessage === - ` > Prefix for user ${bot.options.username} set to: [Prefix: ${config.prefixes[0]}]` - ) - prefix = true; - else if ( - stringMessage?.startsWith( - ` > Prefix for user ${bot.options.username} set to: `, - ) || - stringMessage === - ` > Prefix for user ${bot.options.username} removed.` - ) - prefix = false; - else if (stringMessage === `You no longer have a nickname.`) - nickname = false; - else if (stringMessage?.startsWith("Your nickname is now ")) - nickname = true; - else if ( - stringMessage === `Vanish for ${bot.options.username}: enabled` - ) - vanished = true; - else if ( - stringMessage === `Vanish for ${bot.options.username}: disabled` - ) - vanished = false; - } else if (options.mode === "kaboom") { - if (stringMessage === "Successfully enabled CommandSpy") - commandSpy = true; - else if (stringMessage === "Successfully enabled CommandSpy.") - commandSpy = true; - else if (stringMessage === "Successfully disabled CommandSpy") - commandSpy = false; - else if (stringMessage === "Successfully disabled CommandSpy.") - commandSpy = false; - else if ( - stringMessage === `Vanish for ${bot._client.username}: enabled` - ) - vanished = true; - else if ( - stringMessage === `Vanish for ${bot._client.username}: disabled` - ) - vanished = false; - else if ( - stringMessage === - `You now have the tag: &8[&bPrefix&8: &3${config.prefixes[0]}&8]` || - stringMessage === - "Something went wrong while saving the prefix. Please check console." - ) - prefix = true; - else if ( - stringMessage?.startsWith("You now have the tag: ") || - stringMessage === "You no longer have a tag" - ) - prefix = false; - else if (stringMessage?.startsWith("You have been muted")) - unmuted = true; - else if (stringMessage?.startsWith("You have been unmuted")) - unmuted = false; - else if (stringMessage?.startsWith("Your voice has been silenced")) - unmuted = true; - else if (stringMessage === "God mode disabled.") god = false; - else if (stringMessage === "God mode enabled.") god = true; - else if (stringMessage === "Teleportation disabled.") - teleportToggle = true; - else if (stringMessage === "Teleportation enabled.") - teleportToggle = false; - else if ( - stringMessage === - `Successfully set your username to "${bot._client.username}"` - ) { - username = false; - return; - } else if ( - stringMessage?.startsWith("Successfully set your username to ") - ) - username = true; - else if ( - stringMessage === - `You already have the username "${bot._client.username}"` - ) - username = false; - else if (stringMessage === `You no longer have a nickname.`) - nickname = false; - else if (stringMessage?.startsWith("Your nickname is now ")) - nickname = true; - } + loadMessageSelfcare = require(path.join(__dirname, '../selfcare/message', file)) } catch (e) { - console.log(e.stack); + console.error(e.stack) } - }); + } - bot.on("packet.entity_status", (packet) => { - if ( - packet.entityId !== entityId || - packet.entityStatus < 24 || - packet.entityStatus > 28 - ) - return; - permissionLevel = packet.entityStatus - 24; - }); - - bot.on("packet.game_state_change", (packet) => { - if (packet.reason !== 3) return; // Reason 3 = Change Game Mode - gameMode = packet.gameMode; - }); - - bot.on("packet.position", (packet, position) => { - if (options.mode === "savageFriends" || options.mode === "creayun") - return; - positionCount++; - setTimeout(() => { - positionCount--; - if (positionCount > 4) { - bot._client.end("anti icu"); - } - }, 1000); - }); + for (const file of fs.readdirSync(path.join(__dirname, '../selfcare/entity'))) { + try { + const loadEntitySelfcare = require(path.join(__dirname, '../selfcare/entity', file)) + const entitySelfcare = new loadEntitySelfcare({ bot, config, options }) + } catch (e) { + console.error(e.stack) + } + } // how the fuck do i want to implement this... + bot.on('message', (message) => { + const stringMessage = bot.getMessageAsPrismarine(message)?.toString() + //new loadMessageSelfcare({ bot, options, config, stringMessage }) + }) let timer; - bot.on("packet.login", async (packet) => { - entityId = packet.entityId; + bot.on('packet.login', (data) => { + bot.selfcare.entityId = data.entityId; if (bot.options.version === "1.21" || bot.options.version === "1.21.1") { - clientLock = packet.worldState.gameMode; - switch (packet.worldState.gamemode) { + switch (data.worldState.gamemode) { case "survival": - gameMode = 0; + bot.selfcare.gameMode = 0; break; case "creative": gameMode = 1; break; case "adventure": - gameMode = 2; + bot.selfcare.gameMode = 2; break; case "spectator": - gameMode = 3; + bot.selfcare.gameMode = 3; break; default: - gameMode = 0; + bot.selfcare.gameMode = 0; break; } } else { - gameMode = packet.gameMode; - clientLock = packet.gameMode; + bot.selfcare.gameMode = data.gameMode; } - timer = setInterval(() => { - if (bot.options.mode === "savageFriends") { - if (login) { - bot.chat.command("login amogusissus"); - loggedin = true - } - else if (register) { - bot.chat.command("register amogusissus amogusissus"); - loggedin = true - } - else if (gameMode !== 1 && loggedin) - bot.chat.command("minecraft:gamemode creative"); - else if (permissionLevel < 2 && loggedin) - bot.chat.command(`minecraft:op ${bot.options.username}`); - else if (!prefix && loggedin) - bot.chat.command(`rank ${bot.options.username} &8[&bPrefix&8: &3${config.prefixes[0]}&8]`); - else if (nickname && loggedin) bot.chat.command("nick off"); - else if (!vanished && bot.vanished && loggedin) - bot.chat.command("essentials:vanish on"); - else if (clientLock !== 4) - bot._client.write("client_command", { actionId: 0 }); - } else if ( - bot.options.isCreayun && - !bot.options.isKaboom && - !bot.options.isSavage - ) { - } else if (bot.options.mode === "kaboom") { - if (permissionLevel < 2) bot.chat.command("op @s[type=player]"); - else if (gameMode !== 1) - bot.chat.command("minecraft:gamemode creative"); - else if (username) - bot.chat.command(`username ${bot._client.username}`); - else if (nickname) bot.chat.command(`nick off`); - else if (!prefix) - bot.chat.command( - `prefix &8[&bPrefix&8: &3${config.prefixes[0]}&8]`, - ); - else if (!vanished && bot.vanished) - bot.core.run(`essentials:vanish ${bot._client.username} on`); - else if (!commandSpy) bot.core.run(`commandspy ${bot.uuid} on`); - else if (unmuted) bot.core.run(`essentials:mute ${bot.uuid}`); - else if (!god) bot.core.run(`god ${bot.options.username} enable`); - else if (!teleportToggle) - bot.core.run(`tptoggle ${bot.options.username} disable`); - else if (clientLock !== 4) - bot._client.write("client_command", { actionId: 0 }); - } - }, options.selfcareInterval); - }); - bot.on("end", () => { - if (timer) clearInterval(timer); - prefix = false; - commandSpy = false; - vanished = false; - prefix = false; - god = false; - unmuted = false; - username = false; - loggedin = false - }); + if (bot.selfcare.permissionLevel < 2) bot.chat.command('minecraft:op @s[type=player]') + else if (bot.selfcare.gameMode !== 1) bot.chat.command('minecraft:gamemode creative') + //else if (!bot.selfcare.commandSpy) bot.core.run(`commandspy ${bot.uuid} on`) + }, options.selfcareInterval) + }) + + bot.on('end', () => { + if (timer) clearInterval(timer) + bot.selfcare.commandSpy = false + }) } } -module.exports = SelfcareModule; +module.exports = selfcare \ No newline at end of file diff --git a/src/modules/tab_complete.js b/src/modules/tab_complete.js index 665c2dc..c077196 100644 --- a/src/modules/tab_complete.js +++ b/src/modules/tab_complete.js @@ -1,4 +1,4 @@ -class TabCompleteModule { +class tab_complete { constructor(context) { const bot = context.bot; // let aaa cook @@ -18,4 +18,4 @@ class TabCompleteModule { }; } } -module.exports = TabCompleteModule; +module.exports = tab_complete \ No newline at end of file diff --git a/src/modules/validation.js b/src/modules/validation.js index 3907d84..2563501 100644 --- a/src/modules/validation.js +++ b/src/modules/validation.js @@ -1,6 +1,6 @@ const crypto = require("crypto"); -class ValidationModule { +class validation { constructor(context) { const bot = context.bot; const config = context.config; @@ -25,4 +25,4 @@ class ValidationModule { }, 100); } } -module.exports = ValidationModule; +module.exports = validation \ No newline at end of file diff --git a/src/selfcare.js.old b/src/selfcare.js.old new file mode 100644 index 0000000..4059309 --- /dev/null +++ b/src/selfcare.js.old @@ -0,0 +1,255 @@ +const sleep = require("../util/sleep"); + +class SelfcareModule { + constructor(context) { + const bot = context.bot; + const config = context.config; + const options = context.options; + let clientLock; + let entityId; + let permissionLevel = 2; + let unmuted = false; + let gameMode; + let commandSpy = false; + let vanished = false; + let prefix = false; + let god = false; + let teleportToggle = false; + let username = false; + let nickname = false; + let login = false; + let register = false; + let positionCount = 0; + let loggedin = false + bot.vanished = true; + bot.on("message", (data) => { + try { + const stringMessage = bot.getMessageAsPrismarine(data)?.toString(); + if (options.mode === "savageFriends") { + if ( + stringMessage === + "Please, login with the command: /login " + ) + login = true; + else if (stringMessage === "Successful login!") login = false; + else if (stringMessage === "You're already logged in!") login = false; + else if ( + stringMessage === + "Please, register to the server with the command: /register " + ) + register = true; + else if (stringMessage === "This user isn't registered!") + register = true; + else if (stringMessage === "Successfully registered!") + register = false; + else if (stringMessage === "You're already logged in!") + register = false; + else if (stringMessage === "Successful login!") register = false; + else if ( + stringMessage === + ` > Prefix for user ${bot.options.username} set to: [Prefix: ${config.prefixes[0]}]` + ) + prefix = true; + else if ( + stringMessage?.startsWith( + ` > Prefix for user ${bot.options.username} set to: `, + ) || + stringMessage === + ` > Prefix for user ${bot.options.username} removed.` + ) + prefix = false; + else if (stringMessage === `You no longer have a nickname.`) + nickname = false; + else if (stringMessage?.startsWith("Your nickname is now ")) + nickname = true; + else if ( + stringMessage === `Vanish for ${bot.options.username}: enabled` + ) + vanished = true; + else if ( + stringMessage === `Vanish for ${bot.options.username}: disabled` + ) + vanished = false; + } else if (options.mode === "kaboom") { + if (stringMessage === "Successfully enabled CommandSpy") + commandSpy = true; + else if (stringMessage === "Successfully enabled CommandSpy.") + commandSpy = true; + else if (stringMessage === "Successfully disabled CommandSpy") + commandSpy = false; + else if (stringMessage === "Successfully disabled CommandSpy.") + commandSpy = false; + else if ( + stringMessage === `Vanish for ${bot._client.username}: enabled` + ) + vanished = true; + else if ( + stringMessage === `Vanish for ${bot._client.username}: disabled` + ) + vanished = false; + else if ( + stringMessage === + `You now have the tag: &8[&bPrefix&8: &3${config.prefixes[0]}&8]` || + stringMessage === + "Something went wrong while saving the prefix. Please check console." + ) + prefix = true; + else if ( + stringMessage?.startsWith("You now have the tag: ") || + stringMessage === "You no longer have a tag" + ) + prefix = false; + else if (stringMessage?.startsWith("You have been muted")) + unmuted = true; + else if (stringMessage?.startsWith("You have been unmuted")) + unmuted = false; + else if (stringMessage?.startsWith("Your voice has been silenced")) + unmuted = true; + else if (stringMessage === "God mode disabled.") god = false; + else if (stringMessage === "God mode enabled.") god = true; + else if (stringMessage === "Teleportation disabled.") + teleportToggle = true; + else if (stringMessage === "Teleportation enabled.") + teleportToggle = false; + else if ( + stringMessage === + `Successfully set your username to "${bot._client.username}"` + ) { + username = false; + return; + } else if ( + stringMessage?.startsWith("Successfully set your username to ") + ) + username = true; + else if ( + stringMessage === + `You already have the username "${bot._client.username}"` + ) + username = false; + else if (stringMessage === `You no longer have a nickname.`) + nickname = false; + else if (stringMessage?.startsWith("Your nickname is now ")) + nickname = true; + } + } catch (e) { + console.log(e.stack); + } + }); + + bot.on("packet.entity_status", (packet) => { + if ( + packet.entityId !== entityId || + packet.entityStatus < 24 || + packet.entityStatus > 28 + ) + return; + permissionLevel = packet.entityStatus - 24; + }); + + bot.on("packet.game_state_change", (packet) => { + if (packet.reason !== 3) return; // Reason 3 = Change Game Mode + gameMode = packet.gameMode; + }); + + bot.on("packet.position", (packet, position) => { + if (options.mode === "savageFriends" || options.mode === "creayun") + return; + positionCount++; + setTimeout(() => { + positionCount--; + if (positionCount > 4) { + bot._client.end("anti icu"); + } + }, 1000); + }); + + let timer; + bot.on("packet.login", async (packet) => { + entityId = packet.entityId; + if (bot.options.version === "1.21" || bot.options.version === "1.21.1") { + clientLock = packet.worldState.gameMode; + switch (packet.worldState.gamemode) { + case "survival": + gameMode = 0; + break; + case "creative": + gameMode = 1; + break; + case "adventure": + gameMode = 2; + break; + case "spectator": + gameMode = 3; + break; + default: + gameMode = 0; + break; + } + } else { + gameMode = packet.gameMode; + clientLock = packet.gameMode; + } + + timer = setInterval(() => { + if (bot.options.mode === "savageFriends") { + if (login) { + bot.chat.command("login amogusissus"); + loggedin = true + } + else if (register) { + bot.chat.command("register amogusissus amogusissus"); + loggedin = true + } + else if (gameMode !== 1 && loggedin) + bot.chat.command("minecraft:gamemode creative"); + else if (permissionLevel < 2 && loggedin) + bot.chat.command(`minecraft:op ${bot.options.username}`); + else if (!prefix && loggedin) + bot.chat.command(`rank ${bot.options.username} &8[&bPrefix&8: &3${config.prefixes[0]}&8]`); + else if (nickname && loggedin) bot.chat.command("nick off"); + else if (!vanished && bot.vanished && loggedin) + bot.chat.command("essentials:vanish on"); + else if (clientLock !== 4) + bot._client.write("client_command", { actionId: 0 }); + } else if ( + bot.options.isCreayun && + !bot.options.isKaboom && + !bot.options.isSavage + ) { + } else if (bot.options.mode === "kaboom") { + if (permissionLevel < 2) bot.chat.command("op @s[type=player]"); + else if (gameMode !== 1) + bot.chat.command("minecraft:gamemode creative"); + else if (username) + bot.chat.command(`username ${bot._client.username}`); + else if (nickname) bot.chat.command(`nick off`); + else if (!prefix) + bot.chat.command( + `prefix &8[&bPrefix&8: &3${config.prefixes[0]}&8]`, + ); + else if (!vanished && bot.vanished) + bot.core.run(`essentials:vanish ${bot._client.username} on`); + else if (!commandSpy) bot.core.run(`commandspy ${bot.uuid} on`); + else if (unmuted) bot.core.run(`essentials:mute ${bot.uuid}`); + else if (!god) bot.core.run(`god ${bot.options.username} enable`); + else if (!teleportToggle) + bot.core.run(`tptoggle ${bot.options.username} disable`); + else if (clientLock !== 4) + bot._client.write("client_command", { actionId: 0 }); + } + }, options.selfcareInterval); + }); + bot.on("end", () => { + if (timer) clearInterval(timer); + prefix = false; + commandSpy = false; + vanished = false; + prefix = false; + god = false; + unmuted = false; + username = false; + loggedin = false + }); + } +} +module.exports = SelfcareModule; diff --git a/src/selfcare/entity/gamemode.js b/src/selfcare/entity/gamemode.js new file mode 100644 index 0000000..ccc6765 --- /dev/null +++ b/src/selfcare/entity/gamemode.js @@ -0,0 +1,15 @@ +class gamemodeSelfcare { + constructor (context) { + const bot = context.bot + const config = context.config + const options = context.options + bot.selfcare.gameMode = null + + bot.on("packet.game_state_change", (packet) => { + if (packet.reason !== 3) return; // Reason 3 = Change Game Mode + bot.selfcare.gameMode = packet.gameMode; + }); + } +} + +module.exports = gamemodeSelfcare \ No newline at end of file diff --git a/src/selfcare/entity/op.js b/src/selfcare/entity/op.js new file mode 100644 index 0000000..df61a25 --- /dev/null +++ b/src/selfcare/entity/op.js @@ -0,0 +1,20 @@ +class opSelfcare { + constructor (context) { + const bot = context.bot; + const config = context.config + const options = context.options + bot.selfcare.entityId = undefined + + bot.on("packet.entity_status", (packet) => { + if ( + packet.entityId !== bot.selfcare.entityId || + packet.entityStatus < 24 || + packet.entityStatus > 28 + ) + return; + bot.selfcare.permissionLevel = packet.entityStatus - 24; + }); + } +} + +module.exports = opSelfcare \ No newline at end of file diff --git a/src/selfcare/message/commandSpy.js b/src/selfcare/message/commandSpy.js new file mode 100644 index 0000000..33e9ba6 --- /dev/null +++ b/src/selfcare/message/commandSpy.js @@ -0,0 +1,17 @@ +class commandSpySelfcare { + constructor (context) { + const bot = context.bot + const stringMessage = context.stringMessage + + if (stringMessage === "Successfully enabled CommandSpy") + bot.selfcare.commandSpy = true; + else if (stringMessage === "Successfully enabled CommandSpy.") + bot.selfcare.commandSpy = true; + else if (stringMessage === "Successfully disabled CommandSpy") + bot.selfcare.commandSpy = false; + else if (stringMessage === "Successfully disabled CommandSpy.") + bot.selfcare.commandSpy = false; + } +} + +module.exports = commandSpySelfcare \ No newline at end of file diff --git a/src/selfcare/message/prefix.js b/src/selfcare/message/prefix.js new file mode 100644 index 0000000..fc04e29 --- /dev/null +++ b/src/selfcare/message/prefix.js @@ -0,0 +1,15 @@ +class prefixSelfcare { + constructor (context) { + const bot = context.bot + const options = context.options + const stringMessage = context.stringMessage + + if (options.mode === "savageFriends") { + + } else { + + } + } +} + +module.exports = prefixSelfcare \ No newline at end of file