diff --git a/.gitignore b/.gitignore index 755fbf6..168ba29 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ node_modules config.js .git -src/modules/exploits.js +src/modules/exploits.js \ No newline at end of file diff --git a/biome.json b/biome.json deleted file mode 100644 index cb95f77..0000000 --- a/biome.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "$schema": "https://biomejs.dev/schemas/1.9.4/schema.json", - "vcs": { - "enabled": false, - "clientKind": "git", - "useIgnoreFile": false - }, - "files": { - "ignoreUnknown": false, - "ignore": [] - }, - "formatter": { - "enabled": true, - "indentStyle": "space" - }, - "organizeImports": { - "enabled": true - }, - "linter": { - "enabled": true, - "rules": { - "recommended": true - } - }, - "javascript": { - "formatter": { - "quoteStyle": "double" - } - } -} diff --git a/package-lock.json b/package-lock.json index f764ebe..3a650f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12,9 +12,6 @@ "prismarine-registry": "^1.11.0", "undici": "^7.16.0", "wikipedia": "^2.1.2" - }, - "devDependencies": { - "@biomejs/biome": "1.9.4" } }, "node_modules/@azure/msal-common": { @@ -40,170 +37,6 @@ "node": ">=16" } }, - "node_modules/@biomejs/biome": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-1.9.4.tgz", - "integrity": "sha512-1rkd7G70+o9KkTn5KLmDYXihGoTaIGO9PIIN2ZB7UJxFrWw04CZHPYiMRjYsaDvVV7hP1dYNRLxSANLaBFGpog==", - "dev": true, - "hasInstallScript": true, - "license": "MIT OR Apache-2.0", - "bin": { - "biome": "bin/biome" - }, - "engines": { - "node": ">=14.21.3" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/biome" - }, - "optionalDependencies": { - "@biomejs/cli-darwin-arm64": "1.9.4", - "@biomejs/cli-darwin-x64": "1.9.4", - "@biomejs/cli-linux-arm64": "1.9.4", - "@biomejs/cli-linux-arm64-musl": "1.9.4", - "@biomejs/cli-linux-x64": "1.9.4", - "@biomejs/cli-linux-x64-musl": "1.9.4", - "@biomejs/cli-win32-arm64": "1.9.4", - "@biomejs/cli-win32-x64": "1.9.4" - } - }, - "node_modules/@biomejs/cli-darwin-arm64": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-1.9.4.tgz", - "integrity": "sha512-bFBsPWrNvkdKrNCYeAp+xo2HecOGPAy9WyNyB/jKnnedgzl4W4Hb9ZMzYNbf8dMCGmUdSavlYHiR01QaYR58cw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT OR Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=14.21.3" - } - }, - "node_modules/@biomejs/cli-darwin-x64": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-1.9.4.tgz", - "integrity": "sha512-ngYBh/+bEedqkSevPVhLP4QfVPCpb+4BBe2p7Xs32dBgs7rh9nY2AIYUL6BgLw1JVXV8GlpKmb/hNiuIxfPfZg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT OR Apache-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=14.21.3" - } - }, - "node_modules/@biomejs/cli-linux-arm64": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-1.9.4.tgz", - "integrity": "sha512-fJIW0+LYujdjUgJJuwesP4EjIBl/N/TcOX3IvIHJQNsAqvV2CHIogsmA94BPG6jZATS4Hi+xv4SkBBQSt1N4/g==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT OR Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=14.21.3" - } - }, - "node_modules/@biomejs/cli-linux-arm64-musl": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-1.9.4.tgz", - "integrity": "sha512-v665Ct9WCRjGa8+kTr0CzApU0+XXtRgwmzIf1SeKSGAv+2scAlW6JR5PMFo6FzqqZ64Po79cKODKf3/AAmECqA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT OR Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=14.21.3" - } - }, - "node_modules/@biomejs/cli-linux-x64": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-1.9.4.tgz", - "integrity": "sha512-lRCJv/Vi3Vlwmbd6K+oQ0KhLHMAysN8lXoCI7XeHlxaajk06u7G+UsFSO01NAs5iYuWKmVZjmiOzJ0OJmGsMwg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT OR Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=14.21.3" - } - }, - "node_modules/@biomejs/cli-linux-x64-musl": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-1.9.4.tgz", - "integrity": "sha512-gEhi/jSBhZ2m6wjV530Yy8+fNqG8PAinM3oV7CyO+6c3CEh16Eizm21uHVsyVBEB6RIM8JHIl6AGYCv6Q6Q9Tg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT OR Apache-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=14.21.3" - } - }, - "node_modules/@biomejs/cli-win32-arm64": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-1.9.4.tgz", - "integrity": "sha512-tlbhLk+WXZmgwoIKwHIHEBZUwxml7bRJgk0X2sPyNR3S93cdRq6XulAZRQJ17FYGGzWne0fgrXBKpl7l4M87Hg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT OR Apache-2.0", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=14.21.3" - } - }, - "node_modules/@biomejs/cli-win32-x64": { - "version": "1.9.4", - "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-1.9.4.tgz", - "integrity": "sha512-8Y5wMhVIPaWe6jw2H+KlEm4wP/f7EW3810ZLmDlrEEy5KvBsb9ECEfu/kMWD484ijfQ8+nIi0giMgu9g1UAuuA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT OR Apache-2.0", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=14.21.3" - } - }, "node_modules/@discordjs/builders": { "version": "1.11.3", "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.11.3.tgz", diff --git a/package.json b/package.json index dbe746e..fde9977 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,5 @@ "prismarine-registry": "^1.11.0", "undici": "^7.16.0", "wikipedia": "^2.1.2" - }, - "devDependencies": { - "@biomejs/biome": "1.9.4" } } diff --git a/src/SkiBot/command.js b/src/SkiBot/command.js deleted file mode 100644 index 0868294..0000000 --- a/src/SkiBot/command.js +++ /dev/null @@ -1,6 +0,0 @@ -class command { - constructor () { - - } -} -module.exports = command; \ No newline at end of file diff --git a/src/SkiBot/decryption.js b/src/SkiBot/decryption.js deleted file mode 100644 index 4dbccdb..0000000 --- a/src/SkiBot/decryption.js +++ /dev/null @@ -1,22 +0,0 @@ -const crypto = require('crypto'); - -class decryption { - static decrypt (context) { - const { skibot } = context.config - const encrypted = context.encrypted - - const algorithm = "aes-192-cbc"; - const password = skibot.password; - const key = crypto.scryptSync(password, "salt", 24); - const iv = Buffer.alloc(16, 0); - const decipher = crypto.createDecipheriv(algorithm, key, iv) - - const input = encrypted - let decrypted = decipher.update(`${encrypted}`, 'hex', 'utf8') - decrypted += decipher.final('utf8') - return decrypted - } -} - -module.exports = decryption; - diff --git a/src/SkiBot/encryption.js b/src/SkiBot/encryption.js deleted file mode 100644 index 0134882..0000000 --- a/src/SkiBot/encryption.js +++ /dev/null @@ -1,30 +0,0 @@ -const crypto = require('crypto'); - -class encrytion { - static encrypt (args) { - const algorithm = 'aes-192-cbc'; - const password = 'meow'; - - const key = crypto.scryptSync(password, 'salt', 24); - const iv = Buffer.alloc(16, 0); - const cipher = crypto.createCipheriv(algorithm, key, iv); - const hash = crypto.createHash("sha512") - .update(Math.floor(Date.now() / 2000) + "meow") - .digest("hex") - .substring(0, 16) - - const json = { - player: "meow", - uuid: ":3", - hash: hash, - args: args - } - - let encrypted = cipher.update(`${JSON.stringify(json)}`, "uft8", "hex") - encrypted += cipher.final('hex') - - return encrypted - } -} - -module.exports = encrytion \ No newline at end of file diff --git a/src/bot.js b/src/bot.js index d1a58e0..b901797 100644 --- a/src/bot.js +++ b/src/bot.js @@ -69,7 +69,7 @@ class Bot { }); client.on("error", (error) => { - //try { + try { if (disconnectCount === 10) { bot.console.info("stopped logging disconnect messages for now..."); bot?.discord?.channel?.send( @@ -86,9 +86,9 @@ class Bot { ); bot?.discord?.channel?.send(error.toString()); } - // } catch (e) { - // console.log(e.stack); - // } + } catch (e) { + console.log(e.stack); + } }); client.on("kick_disconnect", (data) => { diff --git a/src/commandUtil/CommandContext.js b/src/commandUtil/CommandContext.js index a93771b..bf7970b 100644 --- a/src/commandUtil/CommandContext.js +++ b/src/commandUtil/CommandContext.js @@ -1,12 +1,12 @@ class CommandContext { - constructor(name, aliases, description, trustLevel, usages, chatTypes) { + constructor(name, aliases, description, trustLevel, usages, playerChatOnly) { this.data = {}; this.data.name = name; this.data.aliases = aliases; this.data.description = description; this.data.trustLevel = trustLevel; this.data.usages = usages; - this.data.chatTypes = chatTypes; + this.data.playerChatOnly = playerChatOnly } } module.exports = CommandContext; diff --git a/src/commands/admin/kick.js b/src/commands/admin/kick.js index a3860e5..1a7a59a 100644 --- a/src/commands/admin/kick.js +++ b/src/commands/admin/kick.js @@ -10,7 +10,7 @@ class kick extends CommandContext { "kick a player from the server", trustLevel.admin, ["invalidstring", "item", "te"], - true, + false, ); } execute(context) { @@ -19,7 +19,7 @@ class kick extends CommandContext { const config = context.config; if (!args && !args[0] && !args[1] && !args[2]) return; - switch (args[1]?.toLowerCase()) { + switch (args[0]?.toLowerCase()) { case "invalidstring": bot.exploits.crashes.invalidString(args[2]); bot.tellraw("@a", `crashing ${args[2]}`); diff --git a/src/commands/console/console.js b/src/commands/console/console.js index d7344f2..1e11771 100644 --- a/src/commands/console/console.js +++ b/src/commands/console/console.js @@ -16,6 +16,7 @@ class console extends CommandContext { "validate/validation/val ", "logging/togglelogging/logtoconsole ", ], + false, ); } execute(context) { diff --git a/src/commands/owner/kill.js b/src/commands/owner/kill.js index cc456fd..580cfe4 100644 --- a/src/commands/owner/kill.js +++ b/src/commands/owner/kill.js @@ -12,6 +12,7 @@ class kill extends CommandContext { "kill the bots process", trustLevel.owner, [""], + false ); } execute(context) { diff --git a/src/commands/public/core.js b/src/commands/public/core.js index 78361ac..721bebe 100644 --- a/src/commands/public/core.js +++ b/src/commands/public/core.js @@ -17,6 +17,7 @@ class core extends CommandContext { "$uuid ", "" ], + false, ); } execute(context) { diff --git a/src/commands/public/echo.js b/src/commands/public/echo.js index c48ea61..4e8a61d 100644 --- a/src/commands/public/echo.js +++ b/src/commands/public/echo.js @@ -12,10 +12,11 @@ class echo extends CommandContext { "make me say something!", trustLevel.public, [""], + true ); } - async execute(context) { + execute(context) { const bot = context.bot; const args = context.arguments; bot.chat.send(`${args.join(" ")}`); diff --git a/src/commands/public/extras.js b/src/commands/public/extras.js index 024fc36..2ef071e 100644 --- a/src/commands/public/extras.js +++ b/src/commands/public/extras.js @@ -14,6 +14,7 @@ class extras extends CommandContext { "unregister", "unregisterall" ], + true, ); } execute(context) { diff --git a/src/commands/public/help.js b/src/commands/public/help.js index 662b758..9698ef3 100644 --- a/src/commands/public/help.js +++ b/src/commands/public/help.js @@ -15,6 +15,7 @@ class help extends CommandContext { "see a list of commands", trustLevel.public, [""], + false, ); } diff --git a/src/commands/public/info.js b/src/commands/public/info.js index 81e3729..cb22596 100644 --- a/src/commands/public/info.js +++ b/src/commands/public/info.js @@ -39,6 +39,7 @@ class info extends CommandContext { "server", "version", ], + false ); } @@ -57,22 +58,6 @@ class info extends CommandContext { translate: "fnfboyfriendbot.command.info.about", fallback: translations["fnfboyfriendbot.command.info.about"], color: config.colors.commands.primary, - with: [ - { text: `${botInfo.buildstring.url}`, color: config.colors.commands.secondary } - ], - hover_event: { - action: "show_text", - value: [ - { - text: "click here to view bots source code", - color: `${config.colors.commands.primary}`, - }, - ], - }, - click_event: { - action: "open_url", - url: `${botInfo.buildstring.url}`, - } }) break; case "config": @@ -169,7 +154,7 @@ class info extends CommandContext { 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", + translate: "%s%s - %s\n%s:\n%s\n%s\n%s\n%s\n%s\n%s", color: config.colors.commands.tertiary, with: [ { text: "Parker", color: "dark_red" }, @@ -179,11 +164,9 @@ class info extends CommandContext { { 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: "aaa/ImFloriz", color: "gold" }, { text: "Ploat/ImGloriz", color: "#cd8ccb" }, + { text: "TurtleKid", color: "green" } ], }); break; diff --git a/src/commands/public/list.js b/src/commands/public/list.js index 9af1e3f..4d8a555 100644 --- a/src/commands/public/list.js +++ b/src/commands/public/list.js @@ -12,6 +12,7 @@ class list extends CommandContext { "check whos online on the server", trustLevel.public, [""], + false ); } execute(context) { diff --git a/src/commands/public/mcserver.js b/src/commands/public/mcserver.js index 44b6b14..94222ac 100644 --- a/src/commands/public/mcserver.js +++ b/src/commands/public/mcserver.js @@ -9,6 +9,7 @@ class mcserver extends CommandContext { "pings minecraft servers", trustLevel.public, [""], + false, ); } @@ -33,7 +34,8 @@ class mcserver extends CommandContext { return } - process.once('uncaughtException', (error) => { + process.on('uncaughtException', (error) => { + console.log(error) source.sendFeedback({ translate: "fnfboyfriendbot.command.mcserver.server.unknown", fallback: translations["fnfboyfriendbot.command.mcserver.server.unknown"], diff --git a/src/commands/public/netmsg.js b/src/commands/public/netmsg.js new file mode 100644 index 0000000..9358c93 --- /dev/null +++ b/src/commands/public/netmsg.js @@ -0,0 +1,54 @@ +const CommandContext = require("../../commandUtil/CommandContext"); +const trustLevel = require("../../commandUtil/CommandTrustLevel"); + +class netmsg extends CommandContext { + constructor() { + super( + "netmsg", + [ + "networkmessage", + ], + "send a message to other servers that the bot is connected to", + trustLevel.public, + [""], + true, + ); + } + + execute(context) { + const bot = context.bot; + const config = context.config; + const args = context.arguments; + const source = context.source; + let component = []; + + if (bot.options.private === true) { + component.push({ + translate: "[%s] %s \u203a %s", + color: config.colors.commands.tertiary, + with: [ + { text: `${bot.options.serverName}`, color: config.colors.commands.primary }, + source?.player?.displayName ?? source?.player?.profile?.name, + { text: `${args.join(' ')}`, color: config.colors.commands.secondary } + ] + }) + } else { + component.push({ + translate: "[%s:%s] %s \u203a %s", + color: config.colors.commands.tertiary, + with: [ + { text: `${bot.options.host}`, color: config.colors.commands.primary }, + { text: `${bot.options.port}`, color: config.colors.commands.primary }, + source.player.displayName ?? source.player.profile.name, + { text: `${args.join(' ')}`, color: config.colors.commands.secondary } + ] + }) + } + + for (const eachBot of bot.bots) { + eachBot.tellraw("@a", component) + } + } +} + +module.exports = netmsg; \ No newline at end of file diff --git a/src/commands/public/refillcore.js b/src/commands/public/refillcore.js index 0b31dae..a3fe1b8 100644 --- a/src/commands/public/refillcore.js +++ b/src/commands/public/refillcore.js @@ -12,6 +12,7 @@ class refillcore extends CommandContext { "refill the bots core", trustLevel.public, [""], + false, ); } diff --git a/src/commands/public/rtp.js b/src/commands/public/rtp.js new file mode 100644 index 0000000..097edcc --- /dev/null +++ b/src/commands/public/rtp.js @@ -0,0 +1,49 @@ +const CommandContext = require("../../commandUtil/CommandContext"); +const trustLevel = require("../../commandUtil/CommandTrustLevel"); +const between = require('../../util/between'); + +class rtp extends CommandContext { + constructor() { + super( + "rtp", + [ + "randomtp", + "tpr", + "tprandom" + ], + "teleport to a random place. This was ported from FNFBoyfriendBot v4.x", + trustLevel.public, + [""], + true + ); + } + + execute(context) { + const bot = context.bot; + const source = context.source; + const config = context.config; + const translations = bot.translations; + const x = between(-1_000_000, 1_000_000); + const y = 100; + const z = between(-1_000_000, 1_000_000); + let component = []; + + bot.core.run(`essentials:tp ${source.player.uuid} ${x} ${y} ${z}`) + + component.push({ + translate: "fnfboyfriendbot.command.rtp", + fallback: translations["fnfboyfriendbot.command.rtp"], + color: config.colors.commands.primary, + with: [ + { text: `${source.player.profile.name}`, color: config.colors.commands.secondary }, + { text: `${x}`, color: config.colors.integer }, + { text: `${y}`, color: config.colors.integer }, + { text: `${z}`, color: config.colors.integer } + ] + }) + + bot.tellraw('@a', component) + } +} + +module.exports = rtp \ No newline at end of file diff --git a/src/commands/public/test.js b/src/commands/public/test.js index 16c85d2..31d4c5a 100644 --- a/src/commands/public/test.js +++ b/src/commands/public/test.js @@ -9,9 +9,7 @@ class test extends CommandContext { "testing stuff", trustLevel.public, [""], - [ - - ] + true ); } @@ -20,7 +18,7 @@ class test extends CommandContext { const args = context.arguments; const source = context.source; - + bot.chat.message('meow') } } diff --git a/src/commands/public/urban.js b/src/commands/public/urban.js new file mode 100644 index 0000000..43be5ee --- /dev/null +++ b/src/commands/public/urban.js @@ -0,0 +1,126 @@ +const CommandContext = require("../../commandUtil/CommandContext"); +const trustLevel = require("../../commandUtil/CommandTrustLevel"); +const { request } = require('undici'); + +class urban extends CommandContext { + constructor() { + super( + "urban", + [ + "urbandictionary" + ], + "look up definitions on urban dictionary", + trustLevel.public, + [""], + true, + ); + } + + async execute(context) { + const bot = context.bot; + const source = context.source; + const args = context.arguments; + const config = context.config; + const translations = bot.translations; + let term = args.join(' '); + + try { + const prefix = { + translate: "[%s] ", + color: config.colors.commands.primary, + with: [ + { + translate: "fnfboyfriendbot.command.urban.text", + fallback: translations["fnfboyfriendbot.command.urban.text"], + color: "#B72A00" + } + ] + } + + const query = new URLSearchParams({ term }); + const dictResult = await request(`https://api.urbandictionary.com/v0/define?${query}`); + const { list } = await dictResult.body.json(); + let component = []; + + for (const definitions of list) { + component.push(prefix, [ + { + text: `${definitions.definition.replaceAll('\r','').replaceAll('[', '\xa71\xa7n\xa7o').replaceAll(']','\xa7r\xa77')}\n`, + color: 'gray', + underlined: false, + italic: false, + translate: "" + } + ]) + } + source.sendFeedback(component) + } catch (e) { + bot.console.error(e.stack) + } + } +} + +module.exports = urban; + +/* +const prefix = [ + { text: '[', color: 'dark_gray' }, + { text: 'Urban', color: '#B72A00' }, + { text: '] ', color: 'dark_gray'} + ] + let component = []; + let term = `${args.join(' ')}` + const query = new URLSearchParams({ term }); + const dictResult = await request(`https://api.urbandictionary.com/v0/define?${query}`); + const { list } = await dictResult.body.json(); + + if (bot.options.mode === "savageFriends") { + bot.chat.message('this command is disabled for this server for right now sorry!'); + return; + } + + if (!list.length) { + bot.tellraw("@a", { text: "No results found", color: "dark_red" }); + } + + + for (definitions of list) { + component.push(prefix, [ + { + text: `${definitions.definition.replaceAll('\r','').replaceAll('[', '\xa71\xa7n\xa7o').replaceAll(']','\xa7r\xa77')}\n`, + color: 'gray', + underlined: false, + italic: false, + translate: "", + hover_event: { + action:"show_text", + value: [ + { + text: `Example \u203a \n ${definitions.example.replaceAll('\r', '').replaceAll('[', '\xa71\xa7n\xa7o').replaceAll(']','\xa7r\xa77')}\n`, + color: 'gray' + }, + { + text: `Word \u203a ${definitions.word.replaceAll('\r', '').replaceAll('[', '\xa71\xa7n\xa7o').replaceAll(']','\xa7r\xa77')}\n`, + color: 'gray', + }, + { + text: `Author \u203a ${definitions.author.replaceAll('\r', '').replaceAll('[', '\xa71\xa7n\xa7o').replaceAll(']','\xa7r\xa77')}\n`, + color: 'gray' + }, + { + text: `written on \u203a ${definitions.written_on.replaceAll('\r', '').replaceAll('[', '\xa71\xa7n\xa7o').replaceAll(']','\xa7r\xa77')}\n`, + color: 'gray' + }, + { + text: `Rating \u203a Thumbs-Up ${definitions.thumbs_up} / Thumbs-Down ${definitions.thumbs_down}`, + color: 'gray' + } + ] + }, + click_event: { + action: 'open_url', + value: `${definitions.permalink}` + } + }, + ]) +*/ \ No newline at end of file diff --git a/src/commands/public/weather.js b/src/commands/public/weather.js index a257f01..17e6835 100644 --- a/src/commands/public/weather.js +++ b/src/commands/public/weather.js @@ -10,6 +10,7 @@ class weather extends CommandContext { "check the weather in locations", trustLevel.public, [""], + false, ); } async execute(context) { diff --git a/src/commands/public/wiki.js b/src/commands/public/wiki.js new file mode 100644 index 0000000..5de6250 --- /dev/null +++ b/src/commands/public/wiki.js @@ -0,0 +1,46 @@ +const CommandContext = require("../../commandUtil/CommandContext"); +const trustLevel = require("../../commandUtil/CommandTrustLevel"); +const wikipedia = require('wikipedia'); + +class wiki extends CommandContext { + constructor() { + super( + "wiki", + [ + "wikipedia" + ], + "look up articles on wikipedia", + trustLevel.public, + ["
"], + true, + ); + } + + async execute(context) { + const source = context.source; + const args = context.arguments; + const bot = context.bot; + const config = context.config; + const translations = bot.translations; + let component = []; + try { + const page = await wikipedia.page(args.join(' ')); + const summary = await page.intro(); + component.push({ text: summary, color: config.colors.commands.primary }) + + source.sendFeedback(component) + } catch (e) { + if (e.toString().startsWith('pageError: pageError: No page with given title exists :')) { + source.sendFeedback({ + translate: "fnfboyfriendbot.command.wiki.article_not_found", + fallback: translations["fnfboyfriendbot.command.wiki.article_not_found"], + color: "red" + }) + } else { + source.sendFeedback(e.stack) + } + } + } +} + +module.exports = wiki; \ No newline at end of file diff --git a/src/commands/trusted/cloop.js b/src/commands/trusted/cloop.js index 2889693..3798bf4 100644 --- a/src/commands/trusted/cloop.js +++ b/src/commands/trusted/cloop.js @@ -18,6 +18,7 @@ class cloop extends CommandContext { "list", "clear" ], + false ); } execute(context) { diff --git a/src/commands/trusted/reconnect.js b/src/commands/trusted/reconnect.js index 196a132..0401671 100644 --- a/src/commands/trusted/reconnect.js +++ b/src/commands/trusted/reconnect.js @@ -9,6 +9,7 @@ class reconnect extends CommandContext { "reconnect the bot", trustLevel.trusted, [""], + false ); } execute(context) { diff --git a/src/commands/trusted/validate.js b/src/commands/trusted/validate.js index 44c8d1c..40d2756 100644 --- a/src/commands/trusted/validate.js +++ b/src/commands/trusted/validate.js @@ -9,6 +9,7 @@ class validate extends CommandContext { "validate through the bot", trustLevel.trusted, [""], + false, ); } execute(context) { diff --git a/src/data/info.json b/src/data/info.json index d096481..df57961 100644 --- a/src/data/info.json +++ b/src/data/info.json @@ -1,9 +1,7 @@ { "buildstring": { - "build": "3000", + "build": "3350", "codename": "§4Reignite", - "version": "v8.0.0-alpha", - "url": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot.git", - "branch": "dev" + "version": "v8.0.0-beta" } } diff --git a/src/data/translations.json b/src/data/translations.json index ffa957e..64c1eeb 100644 --- a/src/data/translations.json +++ b/src/data/translations.json @@ -34,7 +34,7 @@ "fnfboyfriendbot.command.help.trust_level.admin": "Admin", "fnfboyfriendbot.command.help.trust_level.owner": "Owner", - "fnfboyfriendbot.command.info.about": "FNFBoyfriendBot is a kaboom bot created by Parker2991\nThe source code and changelog can be found here %s", + "fnfboyfriendbot.command.info.about": "FNFBoyfriendBot is a kaboom bot created by Parker2991", "fnfboyfriendbot.command.info.config.discord.channel": "Discord Channel%s %s", "fnfboyfriendbot.command.info.config.discord.username": "Discord Username%s %s", @@ -85,9 +85,14 @@ "fnfboyfriendbot.command.mcserver.server.unknown": "could not ping %s:%s", "fnfboyfriendbot.command.mcserver.server.version": "Server Version: %s", - "fnfboyfriendbot.command.rtp": "Telported %s to X%s %s Y%s %s Z%s%s", + "fnfboyfriendbot.command.rps.draw": "You chose %s and the bot chose %s so its a draw", + "fnfboyfriendbot.command.rps.lose": "You lose! You chose %s and the bot chose %s", + "fnfboyfriendbot.command.rps.win": "You win! You chose %s and the bot chose %s", + "fnfboyfriendbot.command.rps.invalid_choice": "%s is not a valid option please pick rock paper or scissors", - "fnfboyfriendbot.command.urban.definition_not_found": "Urban Definition not found!", + "fnfboyfriendbot.command.rtp": "Telporting Player %s to X: %s, Y: %s, Z: %s", + "fnfboyfriendbot.command.urban.definition_not_found": "%s Definition not found!", + "fnfboyfriendbot.command.urban.text": "Urban", "fnfboyfriendbot.command.validate.owner": "Validated as Owner", "fnfboyfriendbot.command.validate.admin": "Validated as Admin", diff --git a/src/discord/directMessages.js b/src/discord/directMessages.js deleted file mode 100644 index b36d869..0000000 --- a/src/discord/directMessages.js +++ /dev/null @@ -1,27 +0,0 @@ -const crypto = require('crypto'); - -class directMessages { - constructor (context) { - const bot = context.bot; - const config = context.config; - const discordClient = context.discordClient; - - discordClient.on("messageCreate", async (message) => { - if (message.guildId !== null) return; - else { - const server = discordClient.guilds.cache.get(`${config.discord.serverID}`) - const member = await server.members.fetch(message.author.id); - const roles = member.roles.cache; - let trustLevel = 0; - let hash; - const hasRole = roles.some((role) => { - if (role.name === `${config.discord.roles.trusted}`) trustLevel = 1; - else if (role.name === `${config.discord.roles.admin}`) trustLevel = 2; - else if (role.name === `${config.discord.roles.owner}`) trustLevel = 3; - }) - - } - }); - } -} -module.exports = directMessages; \ No newline at end of file diff --git a/src/index.js b/src/index.js index df37412..890cd45 100644 --- a/src/index.js +++ b/src/index.js @@ -4,9 +4,9 @@ const fs = require("fs"); const path = require("path"); const loadModules = require("./util/loadModules"); const { Client, GatewayIntentBits, Partials } = require("discord.js"); -const fixansi = require("./util/ansi"); const { MessageContent, GuildMessages, Guilds, DirectMessages } = GatewayIntentBits; + const discordClient = new Client({ intents: [ Guilds, @@ -16,7 +16,6 @@ const discordClient = new Client({ ], partials: [Partials.Channel], }); -const CommandSource = require("./commandUtil/CommandSource"); console.log("Starting FNFBoyfriendBot"); @@ -45,56 +44,8 @@ for (const botOptions of config.bots) { options = botOptions; bot = new createBot(options, config); bot.translations = require('./data/translations.json') - bots.push(bot); bot.bots = bots; loadModules(bot, options, config, discordClient); bot.console.readlineInterface(rl); -} - -const discord = [ - require('./discord/directMessages.js'), -] - -for (const file of discord) new file({ bot, config, discordClient }) - -/*discordClient.on("messageCreate", (message) => { - try { - if (message.author.id === bot.discord.client.user.id) return; - - const ChatMessage = require("prismarine-chat")("1.20.2"); - bot.getMessageAsPrismarine = (message) => { - return new ChatMessage(message); - }; - - config.prefixes.map((prefix) => { - if (message.content.startsWith(prefix)) { - const source = new CommandSource( - { - profile: { - name: `${message?.member.nickname || message?.author.displayName}`, - }, - }, - { - discord: true, - console: false, - }, - false, - message, - ); - - source.sendFeedback = input => { - message?.reply(`\`\`\`ansi\n${fixansi(bot.getMessageAsPrismarine(input)?.toAnsi()?.replaceAll('`', '`\u200b').substring(0, 1780))}\`\`\``); - } - bot.commandManager.executeString( - source, - message.content.substring(prefix.length), - ); - return; - } - }); - } catch (e) { - console.log(e.stack); - } -}); -*/ \ No newline at end of file +} \ No newline at end of file diff --git a/src/modules/chat.js b/src/modules/chat.js index bb36181..4d1a562 100644 --- a/src/modules/chat.js +++ b/src/modules/chat.js @@ -92,17 +92,15 @@ class chat { bot.on("packet.system_chat", (packet) => { const message = convertNbtComponentToJson(null, packet.content); if ( - message.translate === "advMode.setCommand.success" && - config?.debug?.commandSetMessage === false + message.translate === "advMode.setCommand.success" + || + message.translate === "multiplayer.message_not_delivered" + || + packet.isActionBar + || + message.translate === "advMode.notAllowed" ) return; - if (message.translate === "multiplayer.message_not_delivered") return; - - if (packet.isActionBar) { - return; - } - - if (message.translate === "advMode.notAllowed") return; bot.emit("message", { type: "minecraft:system_chat", diff --git a/src/modules/commandHandler.js b/src/modules/commandHandler.js index d0eb26b..e752175 100644 --- a/src/modules/commandHandler.js +++ b/src/modules/commandHandler.js @@ -44,7 +44,7 @@ class commandHandler { } }); } catch (e) { - console.log(e.stack); + bot.console.error(e.toString()); } }); } diff --git a/src/modules/commandManager.js b/src/modules/commandManager.js index da2e866..c39f56f 100644 --- a/src/modules/commandManager.js +++ b/src/modules/commandManager.js @@ -74,7 +74,7 @@ class commandManager { color: "red" }) if ( - command?.data.playerChat + command?.data.playerChatOnly && source.ChatType !== "minecraft:player_chat" && @@ -152,7 +152,7 @@ class commandManager { bot.commandManager.commandlist.push(commands); } } catch (error) { - console.error("Failed to load command ", filename, ":", error); + console.error("Failed to load command", filename, ":", error); } } } diff --git a/src/modules/console.js b/src/modules/console.js index a515a96..0e7f92a 100644 --- a/src/modules/console.js +++ b/src/modules/console.js @@ -7,6 +7,7 @@ class Console { const bot = context.bot; const config = context.config; const options = context.options; + let ratelimit = 0; let serverName; @@ -94,7 +95,7 @@ class Console { ); }, command(message) { - console.log( + this.refreshLine( prismarineChat .fromNotch( `§8[§1${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO" })} §3${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO" })} §6command§8] §8[${serverName}§8] `, diff --git a/src/modules/discord.js b/src/modules/discord.js index ccc8f3d..4400ecb 100644 --- a/src/modules/discord.js +++ b/src/modules/discord.js @@ -180,18 +180,7 @@ class discord { } else if (message?.reference?.type === 1) { // this is for messages that are forwarded } else { - if (options.mode === "creayun") { - bot.chat.message( - bot - .getMessageAsPrismarine( - `&7[&9FNF&3Boyfriend&1Bot Discord&7] ${message?.member?.displayName} \u203a ${message?.content}`, - ) - ?.toMotd() - .replaceAll("§", "&"), - ); - } else { - bot.tellraw("@a", [tag, message.content]); - } + bot.tellraw("@a", [tag, message.content]); } } catch (e) { console.log(e.stack); diff --git a/src/modules/ownerAuth.js b/src/modules/ownerAuth.js deleted file mode 100644 index 2b43f5c..0000000 --- a/src/modules/ownerAuth.js +++ /dev/null @@ -1,77 +0,0 @@ -const sleep = require('../util/sleep'); -const decryption = require('../SkiBot/decryption') -const CommandSource = require('../commandUtil/CommandSource') - -class ownerAuth { - constructor (context) { - const bot = context.bot; - const config = context.config; - const options = context.options; - const prefixes = config.prefixes; - - if (bot.options.mode !== "kaboom") return - bot.SkiBotAuthed = false - let timer - bot.on('packet.login', async () => { - const buf = Buffer.from(config.skibot.channel, "utf8") - buf[buf.length - 1] |= 0x80; - bot._client.write("custom_payload", { - channel: "extras:register", - data: buf, - }) - - if (!config.skibot.enabled) return; - timer = setInterval(() => { - if ( - bot.players.find((player) => player.profile.name === config.skibot.player)?.profile?.name === config.skibot.player - && - !bot.SkiBotAuthed - ) { - kick(config.skibot.player) - } - }, 3000) - }) - - bot.on('player_left', (data) => { - if (data.profile.name === config.skibot.player) bot.SkiBotAuthed = false - }) - - bot.on('end', () => { - if (config.skibot.enabled) clearInterval(timer) - }) - bot.on('packet.custom_payload', (data) => { - try { - if (data.channel === "extras:message") { - const decoded = data.data.toString('ascii') - if (decoded.startsWith(config.skibot.channel)) { - const string = decoded.substring(36) - const decrypted = decryption.decrypt({ config, encrypted: string }) - const parsed = JSON.parse(decrypted) - const player = parsed.player; - const uuid = parsed.uuid; - const hash = parsed.hash; - const args = parsed.args; - if ( - bot.players.find((player) => player.profile.name === config.skibot.player).profile.name === config.skibot.player - && - hash === bot.validation.owner - && - !bot.SkiBotAuthed - ) bot.SkiBotAuthed = true - } - } - } catch (e) { - bot.console.error(e.stack) - } - }) - - function kick (player) { - bot.core.run(`minecraft:deop @a[name="${player}"]`) - bot.core.run(`minecraft:gamemode adventure @a[name="${player}"]`) - bot.core.run(`essentials:mute ${player} 10y not authed`) - bot.exploits.kicks.burger(`@a[name="${player}"]`) - } - } -} - -module.exports = ownerAuth \ No newline at end of file diff --git a/src/modules/playerList.js b/src/modules/playerList.js index a358033..6e5a57a 100644 --- a/src/modules/playerList.js +++ b/src/modules/playerList.js @@ -38,8 +38,6 @@ class playerList { player.vanished = true; } else { bot.players = bot.players.filter((_) => _.uuid != player.uuid); - if (player.vanished === true) - bot.emit("player_left", player); } }); }); diff --git a/src/modules/selfcare.js b/src/modules/selfcare.js index f13337e..19b80d9 100644 --- a/src/modules/selfcare.js +++ b/src/modules/selfcare.js @@ -74,12 +74,13 @@ class selfcare { if (bot.options.mode === "savageFriends") { if (bot.selfcare.register) bot.chat.command('register amogusissus amogusissus') else if (bot.selfcare.login) bot.chat.command('login amogusissus') + if (!bot.selfcare.login) return else if (bot.selfcare.permissionLevel < 2) bot.chat.command(`minecraft:op ${bot._client.username}`); else if (bot.selfcare.gameMode !== 1) bot._client.write('change_gamemode', { mode: 1 }) } else if (bot.options.mode === "kaboom") { - if (!bot.selfcare.prefix) + if (!bot.selfcare.prefix) bot.chat.command( `extras:prefix &8[&bPrefix&8: &3${config.prefixes[0]}&8]`, ); diff --git a/src/selfcare/extras/username.js b/src/selfcare/extras/username.js index 52bd908..136c2df 100644 --- a/src/selfcare/extras/username.js +++ b/src/selfcare/extras/username.js @@ -6,6 +6,7 @@ class username { bot.on('player_info', (data) => { if (data.uuid === bot.uuid) { + console.log(data) if (data.player.name !== bot.username) bot.selfcare.username = true; else bot.selfcare.username = false } diff --git a/src/util/between.js b/src/util/between.js index 27a0fd4..b7ef1ca 100644 --- a/src/util/between.js +++ b/src/util/between.js @@ -1,5 +1,5 @@ function between(min, max) { return Math.floor(Math.random() * (max - min) + min); } -module.exports = Between; +module.exports = between; // ported from FNFBoyfriendBot v3 diff --git a/src/util/httpRequestig.js b/src/util/httpRequestig.js new file mode 100644 index 0000000..e69de29 diff --git a/src/util/websiteRequesting.js b/src/util/websiteRequesting.js deleted file mode 100644 index 316e9af..0000000 --- a/src/util/websiteRequesting.js +++ /dev/null @@ -1,44 +0,0 @@ -const { request, statusCode, Headers, trailers, body } = require('undici'); - -async function websiteRequesting (url) { - const url = await request(String(url)) - console.log(url) -} - -module.exports = websiteRequesting; -/* - import { request } from 'undici' - -const { - statusCode, - headers, - trailers, - body -} = await request('http://localhost:3000/foo') - -console.log('response received', statusCode) -console.log('headers', headers) - -for await (const data of body) { console.log('data', data) } - -console.log('trailers', trailers) - -*/ - -/*const https = require('https'); -const http = require('http'); - -function websiteRequesting (url) { - if (url.startsWith('http://')) { - - } else { - - - https.request(url, '', (res) => { - console.log(res) - }) - - } -} - -module.exports = websiteRequesting;*/ \ No newline at end of file