diff --git a/.gitignore b/.gitignore index b3663b0..819881f 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,6 @@ logs midis config.yml .env -amog src/commands/kick.js src/modules/exploits.js src/commands/kick.js diff --git a/hashGen.js b/hashGen.js new file mode 100644 index 0000000..2e74ea2 --- /dev/null +++ b/hashGen.js @@ -0,0 +1,10 @@ +function hashGen () { + const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890`~!@#$%^&*()-_+={}[]\\|;:,.<>/?'; + let username = ''; + for (let i = 0; i < 16; i++ ) { + const randomIndex = Math.floor(Math.random() * characters.length); + username += characters[randomIndex]; + } + return username; + } +console.log(hashGen()) diff --git a/main.sh b/main.sh index 1f3ded7..ac63431 100644 --- a/main.sh +++ b/main.sh @@ -1,5 +1,5 @@ while true; do -echo "Starting FNFBoyfriendBot...." +# echo "Starting FNFBoyfriendBot...." node --max-old-space-size=1000 src/index.js sleep 1 done diff --git a/old/chat_command_handler.js b/old/chat_command_handler.js new file mode 100644 index 0000000..fb20b85 --- /dev/null +++ b/old/chat_command_handler.js @@ -0,0 +1,56 @@ +const CommandSource = require("../CommandModules/command_source"); +const CommandError = require("../CommandModules/command_error"); +//can i change the var? +const { execSync } = require('child_process'); +function chat_command_handler(bot) { + let ratelimit = 0 + bot.on("parsed_message", (data) => { + if (data.type !== "minecraft:chat") return; + + const prefixes = bot.Commands.prefixes; + + prefixes.map((prefix) => { + const plainMessage = bot + .getMessageAsPrismarine(data.contents) + ?.toString(); + if (!plainMessage.startsWith(prefix)) return; + + const command = plainMessage.substring(prefix.length); // if the prefixes are the same length just make it 1 or the length + /* + lifes sus + */ + const source = new CommandSource(data.sender,{ discord: false, console: false }); + bot.sendFeedback = (message) => { + + if (bot.options.useChat) { + bot.tellraw([message]); + } else { + bot.tellraw(["", message]); + } + +}; +bot.sendError = (message) => { + bot.sendFeedback([{ text: '', color: `red` }, message], false) +} +try{ + + ratelimit++ + setTimeout(() => { + ratelimit-- + }, 1000) + if (ratelimit > bot.Commands.ratelimit) { // ,. + bot.sendFeedback({text:'You are using commands too fast!',color:'dark_red'}) + // this isn't blocking running the command you know that right? + } else { + bot.commandManager.executeString(source, command); + }//oh real + + //can i change the variable name so its name isnt confusing? + }catch(e){ + console.log(e.stack) + + }; + }); +})// +} +module.exports = chat_command_handler; \ No newline at end of file diff --git a/src/modules/chatdelay.js b/old/chatdelay.js similarity index 100% rename from src/modules/chatdelay.js rename to old/chatdelay.js diff --git a/package-lock.json b/package-lock.json index ce937d9..c678f03 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6,6 +6,8 @@ "": { "dependencies": { "@vitalets/google-translate-api": "^9.2.0", + "axios": "^1.7.2", + "base64-img": "^1.0.4", "color-convert": "^2.0.1", "cowsay": "^1.6.0", "cowsay2": "^2.0.4", @@ -20,6 +22,7 @@ "prettier": "^3.2.5", "prismarine-chat": "^1.10.1", "prismarine-registry": "^1.7.0", + "request": "^2.88.2", "wikipedia": "^2.1.2" } }, @@ -288,6 +291,15 @@ "resolved": "https://registry.npmjs.org/aes-js/-/aes-js-3.1.2.tgz", "integrity": "sha512-e5pEa2kBnBOgR4Y/p20pskXI74UEz7de8ZGVo58asOtvSVG5YAbJeELPZxOmt+Bnz3rX753YKhfIn4X4l1PPRQ==" }, + "node_modules/ajax-request": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/ajax-request/-/ajax-request-1.2.3.tgz", + "integrity": "sha512-1o4a9TxDmET7NmU8eIeIsV8t1SD7dooKT7wVFgoKDJC++zljg0vLhcPsoBA3Za2bD5A5LJJBMlGoglsTHa517w==", + "dependencies": { + "file-system": "^2.1.1", + "utils-extend": "^1.0.7" + } + }, "node_modules/ajv": { "version": "6.12.6", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", @@ -335,21 +347,51 @@ "resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz", "integrity": "sha512-6i37w/+EhlWlGUJff3T/Q8u1RGmP5wgbiwYnOnbOqvtrPxT63/sYFyP9RcpxtxGymtfA075IvmOnL7ycNOWl3w==" }, + "node_modules/assert-plus": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/assert-plus/-/assert-plus-1.0.0.tgz", + "integrity": "sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==", + "engines": { + "node": ">=0.8" + } + }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, + "node_modules/aws-sign2": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/aws-sign2/-/aws-sign2-0.7.0.tgz", + "integrity": "sha512-08kcGqnYf/YmjoRhfxyu+CLxBjUtHLXLXX/vUfx9l2LYzG3c1m61nrpyFUZI6zeS+Li/wWMMidD9KgrqtGq3mA==", + "engines": { + "node": "*" + } + }, + "node_modules/aws4": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.13.0.tgz", + "integrity": "sha512-3AungXC4I8kKsS9PuS4JH2nc+0bVY/mjgrephHTIi8fpEeGsTHBUJeosp0Wc1myYMElmD0B3Oc4XL/HVJ4PV2g==" + }, "node_modules/axios": { - "version": "1.7.1", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.1.tgz", - "integrity": "sha512-+LV37nQcd1EpFalkXksWNBiA17NZ5m5/WspmHGmZmdx1qBOg/VNq/c4eRJiA9VQQHBOs+N0ZhhdU10h2TyNK7Q==", + "version": "1.7.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.7.2.tgz", + "integrity": "sha512-2A8QhOMrbomlDuiLeK9XibIBzuHeRcqqNOHp0Cyp5EoJ1IFDh+XZH3A6BkXtv0K4gFGCI0Y4BM7B1wOEi0Rmgw==", "dependencies": { "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } }, + "node_modules/base64-img": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/base64-img/-/base64-img-1.0.4.tgz", + "integrity": "sha512-5RVat9C4bkht6kf4nrQy5gDhiLPs6Iq2sptiR8C6DV0yQ+oeo+oydDFEUgbBAW2yTwQNkthtOlAPG50gjUHaTA==", + "dependencies": { + "ajax-request": "^1.2.0", + "file-system": "^2.1.0" + } + }, "node_modules/base64-js": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", @@ -479,6 +521,11 @@ "node": ">=4" } }, + "node_modules/caseless": { + "version": "0.12.0", + "resolved": "https://registry.npmjs.org/caseless/-/caseless-0.12.0.tgz", + "integrity": "sha512-4tYFyifaFfGacoiObjJegolkwSU4xQNGbVgUiNYVUxbQ2x2lUsFvY4hVgVzGiIe6WLOPqycWXA40l+PWsxthUw==" + }, "node_modules/chownr": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.4.tgz", @@ -566,6 +613,11 @@ "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" }, + "node_modules/core-util-is": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/core-util-is/-/core-util-is-1.0.2.tgz", + "integrity": "sha512-3lqz5YjWTYnW6dlDa5TLaTCcShfar1e40rmcJVwCBJC6mWlFuj0eCHIElmG1g5kyuJ/GD+8Wn4FFCcz4gJPfaQ==" + }, "node_modules/cowsay": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/cowsay/-/cowsay-1.6.0.tgz", @@ -652,6 +704,17 @@ "node": ">=10.0.0" } }, + "node_modules/dashdash": { + "version": "1.14.1", + "resolved": "https://registry.npmjs.org/dashdash/-/dashdash-1.14.1.tgz", + "integrity": "sha512-jRFi8UDGo6j+odZiEpjazZaWqEal3w/basFjQHQEwVtZJGDpxbH1MeYluwCS8Xq5wmLJooDlMgvVarmWfGM44g==", + "dependencies": { + "assert-plus": "^1.0.0" + }, + "engines": { + "node": ">=0.10" + } + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -808,6 +871,15 @@ "url": "https://dotenvx.com" } }, + "node_modules/ecc-jsbn": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/ecc-jsbn/-/ecc-jsbn-0.1.2.tgz", + "integrity": "sha512-eh9O+hwRHNbG4BLTjEl3nw044CkGm5X6LoaCf7LPp7UU8Qrt47JYNi6nPX8xjW97TKGKm1ouctg0QSpZe9qrnw==", + "dependencies": { + "jsbn": "~0.1.0", + "safer-buffer": "^2.1.0" + } + }, "node_modules/ecdsa-sig-formatter": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", @@ -858,6 +930,19 @@ "node": ">=6" } }, + "node_modules/extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, + "node_modules/extsprintf": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/extsprintf/-/extsprintf-1.3.0.tgz", + "integrity": "sha512-11Ndz7Nv+mvAC1j0ktTa7fAb0vLyGGX+rMHNBYQviQDGU0Hw7lhctJANqbPhu9nV9/izT/IntTgZ7Im/9LJs9g==", + "engines": [ + "node >=0.6.0" + ] + }, "node_modules/fast-deep-equal": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", @@ -868,6 +953,23 @@ "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", "integrity": "sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw==" }, + "node_modules/file-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/file-match/-/file-match-1.0.2.tgz", + "integrity": "sha512-g9p6bZV3HlSUM35QPvFWiP/PckDVe5jLPDhx6PfMuy06o+htesJTyDu7zRdXnOm3BY8pXmxb+QY5qIcsoWMGNg==", + "dependencies": { + "utils-extend": "^1.0.6" + } + }, + "node_modules/file-system": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/file-system/-/file-system-2.2.2.tgz", + "integrity": "sha512-YgbXEVCu21CfmoeJ1rFLVLPGhW9o7iCzVFqk7ydy2TxF7rXH2YB68CFgDXLOvTD2pMLtg8paVqurzVjxGRdYmw==", + "dependencies": { + "file-match": "^1.0.1", + "utils-extend": "^1.0.4" + } + }, "node_modules/final-stream": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/final-stream/-/final-stream-2.0.4.tgz", @@ -904,6 +1006,14 @@ } } }, + "node_modules/forever-agent": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/forever-agent/-/forever-agent-0.6.1.tgz", + "integrity": "sha512-j0KLYPhm6zeac4lz3oJ3o65qvgQCcPubiyotZrXqEaG4hNagNYO8qdlUrX5vwqv9ohqeT/Z3j6+yW067yWWdUw==", + "engines": { + "node": "*" + } + }, "node_modules/form-data": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", @@ -941,11 +1051,40 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/getpass": { + "version": "0.1.7", + "resolved": "https://registry.npmjs.org/getpass/-/getpass-0.1.7.tgz", + "integrity": "sha512-0fzj9JxOLfJ+XGLhR8ze3unN0KZCgZwiSSDz168VERjK8Wl8kVSdcu2kspd4s4wtAa1y/qrVRiAA0WclVsu0ng==", + "dependencies": { + "assert-plus": "^1.0.0" + } + }, "node_modules/github-from-package": { "version": "0.0.0", "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz", "integrity": "sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==" }, + "node_modules/har-schema": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz", + "integrity": "sha512-Oqluz6zhGX8cyRaTQlFMPw80bSJVG2x/cFb8ZPhUILGgHka9SsokCCOQgpveePerqidZOrT14ipqfJb7ILcW5Q==", + "engines": { + "node": ">=4" + } + }, + "node_modules/har-validator": { + "version": "5.1.5", + "resolved": "https://registry.npmjs.org/har-validator/-/har-validator-5.1.5.tgz", + "integrity": "sha512-nmT2T0lljbxdQZfspsno9hgrG3Uir6Ks5afism62poxqBM6sDnMEuPmzTq8XN0OEwqKLLdh1jQI3qyE66Nzb3w==", + "deprecated": "this library is no longer supported", + "dependencies": { + "ajv": "^6.12.3", + "har-schema": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -961,6 +1100,20 @@ "node": ">= 0.8" } }, + "node_modules/http-signature": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/http-signature/-/http-signature-1.2.0.tgz", + "integrity": "sha512-CAbnr6Rz4CYQkLYUtSNXxQPUH2gK8f3iWexVlsnMeD+GjlsQ0Xsy1cOX+mN3dtxYomRy21CiOzU8Uhw6OwncEQ==", + "dependencies": { + "assert-plus": "^1.0.0", + "jsprim": "^1.2.2", + "sshpk": "^1.7.0" + }, + "engines": { + "node": ">=0.8", + "npm": ">=1.3.7" + } + }, "node_modules/ieee754": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", @@ -1010,6 +1163,11 @@ "node": ">=4" } }, + "node_modules/is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==" + }, "node_modules/isolated-vm": { "version": "4.7.2", "resolved": "https://registry.npmjs.org/isolated-vm/-/isolated-vm-4.7.2.tgz", @@ -1022,6 +1180,11 @@ "node": ">=16.0.0" } }, + "node_modules/isstream": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/isstream/-/isstream-0.1.2.tgz", + "integrity": "sha512-Yljz7ffyPbrLpLngrMtZ7NduUgVvi6wG9RJ9IUcyCd59YQ911PBJphODUcbOVbqYfxe1wuYf/LJ8PauMRwsM/g==" + }, "node_modules/jose": { "version": "4.15.5", "resolved": "https://registry.npmjs.org/jose/-/jose-4.15.5.tgz", @@ -1041,11 +1204,26 @@ "js-yaml": "bin/js-yaml.js" } }, + "node_modules/jsbn": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/jsbn/-/jsbn-0.1.1.tgz", + "integrity": "sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==" + }, + "node_modules/json-schema": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/json-schema/-/json-schema-0.4.0.tgz", + "integrity": "sha512-es94M3nTIfsEPisRafak+HDLfHXnKBhV3vU5eqPcS3flIWqcxJWgXHXiey3YrpaNsanY5ei1VoYEbOzijuq9BA==" + }, "node_modules/json-schema-traverse": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz", "integrity": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==" }, + "node_modules/json-stringify-safe": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", + "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==" + }, "node_modules/jsonwebtoken": { "version": "9.0.2", "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", @@ -1067,6 +1245,20 @@ "npm": ">=6" } }, + "node_modules/jsprim": { + "version": "1.4.2", + "resolved": "https://registry.npmjs.org/jsprim/-/jsprim-1.4.2.tgz", + "integrity": "sha512-P2bSOMAc/ciLz6DzgjVlGJP9+BrJWu5UDGK70C2iweC5QBIeFf0ZXRvGjEj2uYgrY2MkAAhsSWHDWlFtEroZWw==", + "dependencies": { + "assert-plus": "1.0.0", + "extsprintf": "1.3.0", + "json-schema": "0.4.0", + "verror": "1.10.0" + }, + "engines": { + "node": ">=0.6.0" + } + }, "node_modules/jwa": { "version": "1.4.1", "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", @@ -1367,6 +1559,14 @@ "asn1": "0.2.3" } }, + "node_modules/oauth-sign": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/oauth-sign/-/oauth-sign-0.9.0.tgz", + "integrity": "sha512-fexhUFFPTGV8ybAtSIGbV6gOkSv8UtRbDBnAyLQw4QPKkgNlsH2ByPGtMUqdWkos6YCRmAqViwgZrJc/mRDzZQ==", + "engines": { + "node": "*" + } + }, "node_modules/once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", @@ -1416,6 +1616,11 @@ "node": ">=8" } }, + "node_modules/performance-now": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz", + "integrity": "sha512-7EAHlyLHI56VEIdK57uwHdHKIaAGbnXPiw0yWbarQZOKaKpvUIgW0jWRVLiatnM+XXlSwsanIBH/hzGMJulMow==" + }, "node_modules/prebuild-install": { "version": "7.1.2", "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.2.tgz", @@ -1556,6 +1761,11 @@ "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" }, + "node_modules/psl": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", + "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag==" + }, "node_modules/pump": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pump/-/pump-3.0.0.tgz", @@ -1573,6 +1783,14 @@ "node": ">=6" } }, + "node_modules/qs": { + "version": "6.5.3", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.3.tgz", + "integrity": "sha512-qxXIEh4pCGfHICj1mAJQ2/2XVZkjCDTcEgfoSQxc/fYivUZxTkk7L3bDBJSoNrEzXI17oUO5Dp07ktqE5KzczA==", + "engines": { + "node": ">=0.6" + } + }, "node_modules/railroad-diagrams": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/railroad-diagrams/-/railroad-diagrams-1.0.0.tgz", @@ -1619,6 +1837,59 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, + "node_modules/request": { + "version": "2.88.2", + "resolved": "https://registry.npmjs.org/request/-/request-2.88.2.tgz", + "integrity": "sha512-MsvtOrfG9ZcrOwAW+Qi+F6HbD0CWXEh9ou77uOb7FM2WPhwT7smM833PzanhJLsgXjN89Ir6V2PczXNnMpwKhw==", + "deprecated": "request has been deprecated, see https://github.com/request/request/issues/3142", + "dependencies": { + "aws-sign2": "~0.7.0", + "aws4": "^1.8.0", + "caseless": "~0.12.0", + "combined-stream": "~1.0.6", + "extend": "~3.0.2", + "forever-agent": "~0.6.1", + "form-data": "~2.3.2", + "har-validator": "~5.1.3", + "http-signature": "~1.2.0", + "is-typedarray": "~1.0.0", + "isstream": "~0.1.2", + "json-stringify-safe": "~5.0.1", + "mime-types": "~2.1.19", + "oauth-sign": "~0.9.0", + "performance-now": "^2.1.0", + "qs": "~6.5.2", + "safe-buffer": "^5.1.2", + "tough-cookie": "~2.5.0", + "tunnel-agent": "^0.6.0", + "uuid": "^3.3.2" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/request/node_modules/form-data": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz", + "integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.6", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 0.12" + } + }, + "node_modules/request/node_modules/uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "deprecated": "Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.", + "bin": { + "uuid": "bin/uuid" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -1756,6 +2027,30 @@ "safer-buffer": "~2.1.0" } }, + "node_modules/sshpk": { + "version": "1.18.0", + "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.18.0.tgz", + "integrity": "sha512-2p2KJZTSqQ/I3+HX42EpYOa2l3f8Erv8MWKsy2I9uf4wA7yFIkXRffYdsx86y6z4vHtV8u7g+pPlr8/4ouAxsQ==", + "dependencies": { + "asn1": "~0.2.3", + "assert-plus": "^1.0.0", + "bcrypt-pbkdf": "^1.0.0", + "dashdash": "^1.12.0", + "ecc-jsbn": "~0.1.1", + "getpass": "^0.1.1", + "jsbn": "~0.1.0", + "safer-buffer": "^2.0.2", + "tweetnacl": "~0.14.0" + }, + "bin": { + "sshpk-conv": "bin/sshpk-conv", + "sshpk-sign": "bin/sshpk-sign", + "sshpk-verify": "bin/sshpk-verify" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/statuses": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/statuses/-/statuses-2.0.1.tgz", @@ -1877,6 +2172,18 @@ "node": ">=0.6" } }, + "node_modules/tough-cookie": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-2.5.0.tgz", + "integrity": "sha512-nlLsUzgm1kfLXSXfRZMc1KLAugd4hqJHDTvc2hDIwS3mZAfMEuMbc03SujMF+GEcpaX/qboeycw6iO8JwVv2+g==", + "dependencies": { + "psl": "^1.1.28", + "punycode": "^2.1.1" + }, + "engines": { + "node": ">=0.8" + } + }, "node_modules/tr46": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", @@ -1934,6 +2241,11 @@ "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, + "node_modules/utils-extend": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/utils-extend/-/utils-extend-1.0.8.tgz", + "integrity": "sha512-+VzQieEAijyCFGqnGAWIy7Em1dFGdgf1w+orKwmTWHyaGL19aw9Oq5e5ZZaxgcS777AkPYEsbgWqpz5E6KniPg==" + }, "node_modules/uuid": { "version": "8.3.2", "resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz", @@ -1950,6 +2262,19 @@ "macaddress": "^0.5.1" } }, + "node_modules/verror": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/verror/-/verror-1.10.0.tgz", + "integrity": "sha512-ZZKSmDAEFOijERBLkmYfJ+vmk3w+7hOLYDNkRCuRuMJGEmqYNCNLyBBFwWKVMhfwaEF3WOd0Zlw86U/WC/+nYw==", + "engines": [ + "node >=0.6.0" + ], + "dependencies": { + "assert-plus": "^1.0.0", + "core-util-is": "1.0.2", + "extsprintf": "^1.2.0" + } + }, "node_modules/webidl-conversions": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", diff --git a/prototyping-crap/1.20.4-chat.js b/prototyping-crap/1.20.4-chat.js index 103dbdf..cbf14de 100644 --- a/prototyping-crap/1.20.4-chat.js +++ b/prototyping-crap/1.20.4-chat.js @@ -1,58 +1,34 @@ -testdata = { - "extra": [ - { - "extra": [ - { - "bold": 1, - "color": "dark_red", - "text": "[" - }, - { - "bold": 1, - "color": "red", - "text": "OP" - }, - { - "bold": 1, - "color": "dark_red", - "text": "] " - }, - { - "color": "red", - "text": "" - } - ], - "text": "" - }, - { - "extra": [ - { - "color": "red", - "text": "Parker2991" - } - ], - "text": "" - }, - {"":":"}, - {"":" "}, - {"":"e"} - ], - "text": "" -} +const version = '1.20.4' +const { fromNotch } = require('prismarine-chat')(version) +const nbt = require('prismarine-nbt') +//const msg = {"type":"compound","value":{"extra":{"type":"list","value":{"type":"compound","value":[{"extra":{"type":"list","value":{"type":"compound","value":[{"color":{"type":"string","value":"dark_gray"},"text":{"type":"string","value":"["}},{"color":{"type":"string","value":"aqua"},"text":{"type":"string","value":"Prefix: "}},{"color":{"type":"string","value":"dark_red"},"text":{"type":"string","value":"~"}},{"color":{"type":"string","value":"dark_gray"},"text":{"type":"string","value":"]"}},{"":{"type":"string","value":" "}}]}},"text":{"type":"string","value":""}},{"extra":{"type":"list","value":{"type":"compound","value":[{"color":{"type":"string","value":"red"},"text":{"type":"string","value":"FNFBoyfriendBot"}}]}},"text":{"type":"string","value":""}},{"":{"type":"string","value":":"}},{"":{"type":"string","value":" "}},{"extra":{"type":"list","value":{"type":"compound","value":[{"color":{"type":"string","value":"dark_purple"},"text":{"type":"string","value":"FNF"}},{"color":{"type":"string","value":"aqua"},"text":{"type":"string","value":"Boyfriend"}},{"color":{"type":"string","value":"dark_red"},"text":{"type":"string","value":"Bot "}},{"color":{"type":"string","value":"white"},"text":{"type":"string","value":"- "}},{"color":{"type":"string","value":"dark_red"},"text":{"type":"string","value":"Parker"}},{"color":{"type":"string","value":"black"},"text":{"type":"string","value":"2991"}}]}},"text":{"type":"string","value":""}}]}},"text":{"type":"string","value":""}}} +const msg = {"type":"compound","value":{"extra":{"type":"list","value":{"type":"compound","value":[{"extra":{"type":"list","value":{"type":"compound","value":[{"bold":{"type":"byte","value":1},"color":{"type":"string","value":"dark_red"},"text":{"type":"string","value":"["}},{"bold":{"type":"byte","value":1},"color":{"type":"string","value":"red"},"text":{"type":"string","value":"OP"}},{"bold":{"type":"byte","value":1},"color":{"type":"string","value":"dark_red"},"text":{"type":"string","value":"] "}},{"color":{"type":"string","value":"red"},"text":{"type":"string","value":""}}]}},"text":{"type":"string","value":""}},{"extra":{"type":"list","value":{"type":"compound","value":[{"color":{"type":"string","value":"red"},"text":{"type":"string","value":"birdevent"}}]}},"text":{"type":"string","value":""}},{"":{"type":"string","value":":"}},{"":{"type":"string","value":" "}},{"":{"type":"string","value":"?"}}]}},"text":{"type":"string","value":""}}} +function tryParse (json) { -function parseMessage(message, color = true) { - console.log(message); - let ret = "" - if (color) { - for (thing in message) { - console.log(thing); - } - } else { - for (thing in message) { - console.log(thing); - } - } - return ret; } +function processNbtMessage (msg) { + if (!msg || msg.type === 'end') return null + const simplified = nbt.simplify(msg) + const json = JSON.stringify(simplified, (key, val) => { + if (key === 'id' && Array.isArray(val)) return uuidFromIntArray(val) + return val + }) + return json +} +console.log(fromNotch(processNbtMessage(msg)).toAnsi()) +console.log(fromNotch(nbt.simplify(msg).extra).toAnsi()) +async function nbtChat() { -parseMessage(testdata) + const { parsed, type } = await nbt.parse(msg) + console.log(parsed) +} +//nbtChat() +/* +async function main(file) { + const buffer = fs.readFileSync(file) + const { parsed, type } = await nbt.parse(buffer) + console.log('JSON serialized', JSON.stringify(parsed, null, 2)) + fs.createWriteStream('bigtest.nbt').write(nbt.writeUncompressed(parsed, type)) // Write it back +} +main('bigtest.nbt') +*/ diff --git a/prototyping-crap/blacklist.js b/prototyping-crap/blacklist.js new file mode 100644 index 0000000..390271c --- /dev/null +++ b/prototyping-crap/blacklist.js @@ -0,0 +1,7 @@ +const fs = require('fs/promises'); +const path = require('path'); +const blacklist = require(path.join(__dirname, 'blacklist.json')); + +for (const player of blacklist.players) { + console.log('whos blacklisted?',[player]); +} diff --git a/prototyping-crap/blacklist.json b/prototyping-crap/blacklist.json new file mode 100644 index 0000000..82a54cc --- /dev/null +++ b/prototyping-crap/blacklist.json @@ -0,0 +1,8 @@ +{ + "players": [ + "CynicalDev", + "denisapain", + "Pan_Poppo", + "Parker2991" + ] +} diff --git a/prototyping-crap/filter.js b/prototyping-crap/filter.js new file mode 100644 index 0000000..008dedd --- /dev/null +++ b/prototyping-crap/filter.js @@ -0,0 +1,139 @@ +const fs = require('fs'); +const path = require('path'); +const filterList = require('../../filter.json'); +function filter (bot, options) { + function join () { + for (const players of filterList.players) { + bot.on('message', message => { + const stringmessage = bot.getMessageAsPrismarine(message)?.toString() + if ( + stringmessage.startsWith(`${players.username} joined the game`) + ) { + bot.core.run(`/essentials:mute ${players.username} 10y Filtered by FNFBoyfriendBot`); + bot.core.run(`/execute at @e run deop ${players.username}`); + bot.core.run(`/execute at @e run gamemode spectator ${players.username}`); +// bot.core.run(`tellraw ${players.username} ${JSON.stringify(bot.exploits.invalidstring)}`) + } + }) + } + } + function login () { + for (const players of filterList.players) { + bot.on('login', data => { + + if (bot.players.find((player) => player.profile.name === players.username).profile.username) { + bot.core.run(`/essentials:mute ${bot?.players?.find((player) => player?.profile?.name === players?.username).profile?.username} 10y Filtered by FNFBoyfriendBot`); + bot.core.run(`/execute at @e run ${players.username}`); + bot.core.run(`/execute at @e run gamemode spectator ${players.username}`); +// bot.core.run(`tellraw ${players.username} ${JSON.stringify(bot.exploits.invalidstring)}`) + } + }) + } + } + function mute () { + for (const players of filterList.players) { + bot.on('message', (message) => { + const stringmessage = bot.getMessageAsPrismarine(message)?.toString() + if ( + stringmessage.startsWith(`${players.username}: /essentials:mute ${players.username}`) + || + stringmessage === `${players.username}: /essentials:mute ${bot?.players?.find((player) => player?.profile?.name === players?.username)?.uuid}` + || + stringmessage === `${players.username}: /emute ` + || + stringmessage === `${players.username}: /mute ${bot?.players?.find((player) => player?.profile?.name === players?.username)?.uuid}` + || + stringmessage.startsWith(`${players.username}: /emute ${players.username}`) + || + stringmessage.startsWith(`${players.username}: /mute ${players.username}`) + || + stringmessage.includes(`${players.username}: `) + ) { + bot.core.run(`/essentials:mute ${players.username} 10y Filtered by FNFBoyfriendBot`); + //bot.core.run(`tellraw ${players.username} ${JSON.stringify(bot.exploits.invalidstring)}`) + } + }) + } + } + function gamemode () { + for (const players of filterList.players) { + bot.on('message', (message) => { + const stringmessage = bot.getMessageAsPrismarine(message)?.toString(); + if ( + stringmessage.startsWith(`${players.username}: /gamemode creative`) + || + stringmessage.startsWith(`${players.username}: /minecraft:gamemode creative`) + || + stringmessage.startsWith(`${players.username}: /gmc`) + || + stringmessage.startsWith(`${players.username}: /egmc`) + || + stringmessage.startsWith(`${players.username}: /essentials:gamemode creative`) + || + stringmessage.startsWith(`${players.username}: /essentials:gm creative`) + || + stringmessage.startsWith(`${players.username}: /essentials:gmc creative`) + || + stringmessage.startsWith(`: /execute`) + stringmessage.endsWith(`gamemode creative ${players.username}`) + || + stringmessage.startsWith(`${players.username}: /egmc creative`) + || + stringmessage.startsWith(`${players.username}: /gmc creative`) + || + stringmessage.startsWith(`${players.username}: /egm creative`) + || + stringmessage.startsWith(`${players.username}: /egm creative`) + || + bot?.players?.find((player) => player?.profile?.name === players?.username)?.gamemode !== 3 + ) { +// bot.core.run(`gamemode spectator bot?.players?.find((player) => player?.profile?.name === players?.username)?.profile.username}`) + bot.core.run(`/gamemode spectator ${players.username}`); + //bot.core.run(`tellraw ${players.username} ${JSON.stringify(bot.exploits.invalidstring)}`) + bot.core.run(`/execute at @e run deop ${players.username}`); + } + }) + } + } + function deop () { + for (const players of filterList.players) { + bot.on('message', (message) => { + const stringmessage = bot.getMessageAsPrismarine(message)?.toString(); + if ( + stringmessage.startsWith(`${players.username}: /minecraft:op`) + || + stringmessage.startsWith(`${players.username}: /op ${players.username}`) + || + stringmessage.startsWith(`${players.username}: /minecraft:op ${players.username}`) + || + stringmessage.startsWith(`: /execute`) + stringmessage.endsWith(`op ${players.username}`) + || + stringmessage.includes(`${players.username}: `) + ) { + bot.core.run(`execute at @e run deop ${players.username}`) + bot.core.run(`tellraw ${players.username} ${JSON.stringify(bot.exploits.invalidstring)}`) + } + }) + } + } + if (bot.options.isSavage) return + join(); + gamemode(); + mute(); + login(); + deop(); +} +module.exports = filter; +// stringmessage.startsWith(`${players.username}: /essentials:mute ${players.username}`) +// stringmessage.startsWith(`${players.username}: /emute Parker2991`) +// [chipmunkbot§: Made chipmunkbot a server operator] +// stringmessage.startsWith(`${players.username}: /minecraft:op`) +// stringmessage.startsWith(`${players.username}: /op ${players.username}`) +// stringmessage.startsWith(`: /execute`) + stringmessage.endsWith(`op ${players.username}`) +// stringmessage.startsWith(`${players.username}: /gmc`) +// stringmessage.startsWith(`${players.username}: /egmc`) +// stringmessage.startsWith(`${players.username}: /essentials:gamemode creative`) +// stringmessage.startsWith(`${players.username}: /essentials:gm creative`) +// stringmessage.startsWith(`${players.username}: /essentials:gmc creative`) +// stringmessage.startsWith(`: /execute`) + stringmessage.endsWith(`gamemode creative ${players.username}`) + + diff --git a/prototyping-crap/filter.json b/prototyping-crap/filter.json new file mode 100644 index 0000000..f6d44a6 --- /dev/null +++ b/prototyping-crap/filter.json @@ -0,0 +1 @@ +{"players":[{"username":"Bu11D0g1337","ignorecase":false},{"username":"Pringels2","ignorecase":false},{"username":"denisapain","ignorecase":false},{"username":"CynicalDev","ignorecase":false}]} \ No newline at end of file diff --git a/prototyping-crap/filter.txt b/prototyping-crap/filter.txt new file mode 100644 index 0000000..5a19f0c --- /dev/null +++ b/prototyping-crap/filter.txt @@ -0,0 +1,9 @@ + + +e +e +e +e +e +e +e \ No newline at end of file diff --git a/prototyping-crap/index.js b/prototyping-crap/index.js deleted file mode 100644 index bcbcfcf..0000000 --- a/prototyping-crap/index.js +++ /dev/null @@ -1,94 +0,0 @@ -const CommandError = require('./CommandModules/command_error.js'); -const util = require("util"); -const path = require('path'); -const fs = require('fs'); -const parseYaml = require('js-yaml') -/* if (!fs.existsSync('config.js')) { - console.log('Config not found creating config from default.js'); - fs.copyFileSync( - path.join(__dirname, 'default.yml'), - path.join(__dirname, 'config.js'), -); -}; */ -if (!fs.existsSync('config.yml')) { - console.log('Config not found creating config from default.yml'); - fs.copyFileSync( - path.join(__dirname, 'default.yml'), - path.join(__dirname, 'config.yml'), -); -}; -// const config = require(`../config.js`); -try { - config = parseYaml.load(fs.readFileSync('config.yml', 'utf8')); - console.log(config) -} catch (e) { - console.log(e.toString()) -} -const { createBot } = require('./bot.js'); -const readline = require("readline"); - -const rl = readline.createInterface({ - input: process.stdin, - output: process.stdout, -}); - -function load() { - require("dotenv").config(); - const bots = []; - const core = config.Core; - const commands = config.Commands; - const Console = config.console; - const tellrawtag = config.tellrawTag; -// const helptheme = config.helpTheme; - const discord = config.Discord; - const matrix = config.matrix; - const validation = config.validation; -for (const options of config.bots) { - const bot = createBot(options); - bots.push(bot); - bot.bots = bots; - bot.Core = core; - bot.Commands = commands; - bot.Console = Console; - bot.Discord = discord; - bot.tellrawTag = tellrawtag; -// bot.helpTheme = helptheme; - bot.matrix = matrix; - bot.validation = validation; - bot.options.username; - bot.loadModule = (module) => module(bot, options); - - for (const filename of fs.readdirSync(path.join(__dirname, "modules"))) { - try { - const module = require(path.join(__dirname, "modules", filename)); - bot.loadModule(module); - } catch (error) { - console.log( - "Failed to load module", - filename, - ":", - error, - ); - } -} - - - bot.console.useReadlineInterface(rl); - - - try { - bot.on("error", error => { -bot?.console?.warn(error.toString()) -}); - } catch (error) { - console.log(error.stack); - } - - } -} - -process.on("uncaughtException", (e) => { -//console.log(e.stack) -}); - -load() diff --git a/src/CommandModules/e.hx b/src/CommandModules/e.hx deleted file mode 100644 index 1fe01c4..0000000 --- a/src/CommandModules/e.hx +++ /dev/null @@ -1 +0,0 @@ -const haxe = require('haxe-js-kit') diff --git a/src/CommandModules/funni.hx b/src/CommandModules/funni.hx new file mode 100644 index 0000000..ae685a4 --- /dev/null +++ b/src/CommandModules/funni.hx @@ -0,0 +1,5 @@ +class HelloWorld { + static public function main():Void { + trace("Hello World"); + } +} diff --git a/src/bot.js b/src/bot.js index 6cfd9ea..df20d85 100644 --- a/src/bot.js +++ b/src/bot.js @@ -3,7 +3,7 @@ const { EventEmitter } = require("node:events"); const usernameGen = require('./util/usernameGen'); require("events").EventEmitter.defaultMaxListeners = Infinity; const { execSync } = require('child_process'); -function createBot(options = {}) { +function createBot(options = {}, config) { const bot = new EventEmitter(); // Set some default values in options bot.options = { @@ -20,19 +20,19 @@ function createBot(options = {}) { bot.emit("packet", data, meta); bot.emit('packet.' + meta.name, data) }); - const timer = setInterval(() => { - if (!bot.options.endcredits) { +/* const timer = setInterval(() => { + if (!config.bots.endcredits) { return } else { bot.chat(`Join the FNFBoyfriendBot discord ${bot.discord.invite}`) } - }, 280000) + }, 280000)*/ client.on("login", async function (data) { bot.uuid = client.uuid; bot.username = client.username; bot.port = bot.options.port; bot.version = bot.options.version; - if (bot.options.isCreayun) { +/* if (bot.options.isCreayun) { } var day = new Date().getDay() if (day === 5) { @@ -44,11 +44,12 @@ function createBot(options = {}) { if (bot.options.useChat) { bot?.console?.warn(`useChat is active for ${bot.options.host} the bot will not be able to run commands in core`) } else if (bot.options.isCreayun) { - bot?.console?.info(`Creayun mode is active for ${bot.options.host} please not that the bot will not read kaboom commands and messages when Creayun mode is active`) +bot?.console?.info(`Creayun mode is active for ${bot.options.host} please not that the bot will not read kaboom commands and messages when Creayun +mode is active`) } if (bot.options.debug.enabled) { - bot.console.warn(`Debug mode is enabled for ${bot.options.host}:${bot.options.port} please note this WILL spam console is all options are enabled`) - } +bot.console.warn(`Debug mode is enabled for ${bot.options.host}:${bot.options.port} please note this WILL spam console is all options are enabled`) + }*/ }) client.on("end", (reason) => { const parsed = JSON.stringify(reason); @@ -58,7 +59,7 @@ function createBot(options = {}) { bot.memusage.off() bot.tps.off() bot.bruhifyText = '' - clearInterval(timer) +// clearInterval(timer) bot?.discord?.channel?.send('Disconnected: ' + '``' + parsed + '``') }); @@ -66,10 +67,14 @@ function createBot(options = {}) { const parsed = JSON.parse(data.reason) bot.emit(parsed, "disconnect"); if (parsed === 'Server is full!') { - bot.console.warn(`what the fuck?`) + bot.emit("disconnect", `what the fuck?`) + } else if (parsed === 'Wait 5 seconds before connecting, thanks! :)') { + bot.options.reconnectDelay = 1000 * 5 + bot.console.info(`Setting reconnect delay to ${1000 * 5}`) + bot.discord.channel?.send(`Setting reconnecting delay to ${1000 * 5}`) } else { - bot.console.warn(`Disconnected: ${parsed}`); - bot?.discord?.channel?.send('Disconnected: ' + '``' + parsed + '``') + bot.console.warn(`Disconnected: ${JSON.stringify(parsed)}`); + bot?.discord?.channel?.send('Disconnected: ' + '``' + JSON.stringify(parsed) + '``') } }); diff --git a/src/chat/creayun.js b/src/chat/creayun.js index 2185993..6356fcb 100644 --- a/src/chat/creayun.js +++ b/src/chat/creayun.js @@ -1,5 +1,6 @@ function creayun (messageobj, data) { // this function is not getting called - const ChatMessage = require('prismarine-chat')('1.20.1') +const ChatMessage = require('prismarine-chat')('1.20.1') +const util = require('util') const stringify = message => new ChatMessage(message).toString() const message = stringify(messageobj); const playerWithPrefix = /^(.*?) (\S*?) » (.*?)$/; @@ -10,12 +11,32 @@ const stringify = message => new ChatMessage(message).toString() if (playerWithPrefix.test(message)) { // console.log('[debug]', match); let match = message.match(playerWithPrefix) - return { sender: match[2], contents: match[3], type: 'minecraft:chat'}; // -// } else if (playerWithoutPrefix.test(message)) { - //let match = message.match(playerWitoutPrefix) - //return { sender: match[1], contents: match[2], type: 'minecraft:chat'}; + const sender = data.players.find((player) => player.uuid === player.uuid) + if (!sender) return undefined + return { sender, contents: match[3], type: 'minecraft:chat'}; }//i just realized that the bot uses tellraw //ima try to fix that } -module.exports = creayun//:troll: +module.exports = creayun; +// bot.players.find((player) => player.profile.name === players.username) +// let displayName = data.senderName ?? { text: '' } +/* + const playerListDisplayName = { extra: [prefix, displayName], text: '' } + let sender + if (data.uuid) { + sender = data.players.find(player => player.uuid === data.senderUuid) + } else { + const playerListDisplayName = { extra: [prefix, displayName], text: '' } + sender = data.players.find(player => util.isDeepStrictEqual(player.displayName, playerListDisplayName)) + } + if (!sender) return undefined + + return { sender, contents, type: 'minecraft:chat', displayName } +} + +function isSeparatorAt (children, start) { + return (children[start]?.text === ':' || children[start]?.text === '\xa7r:') && children[start + 1]?.text === ' ' +} + +*/ diff --git a/src/chat/savage.js b/src/chat/savage.js index fbbb255..2c2ba72 100644 --- a/src/chat/savage.js +++ b/src/chat/savage.js @@ -9,7 +9,7 @@ function savage (message, data) { const prefix = children[0] let displayName = data.senderName ?? { text: '' } - let contents = { text: '' } + let contents = { text: ' ' } if (isSeparatorAt(children, 1)) { // Missing/blank display name if (children.length > 3) contents = children[3] @@ -19,23 +19,33 @@ function savage (message, data) { } else { return undefined } - - const playerListDisplayName = { extra: [prefix, displayName], text: '' } +/* + if (isSeparatorAt(children, 1)) { // Missing/blank display name + if (children.length > 3) contents = children[3] + } else if (isSeparatorAt(children, 2)) { + displayName = children[1] + if (children.length > 4) contents = children[4] + } else { + return undefined + } +*/ +// let sus = { text: ' ' } + const playerListDisplayName = { extra: [prefix, displayName, content]} let sender if (data.uuid) { sender = data.players.find(player => player.uuid === data.senderUuid) } else { - const playerListDisplayName = { extra: [prefix, displayName], text: '' } + const playerListDisplayName = { extra: [prefix, displayName, content] } sender = data.players.find(player => util.isDeepStrictEqual(player.displayName, playerListDisplayName)) } if (!sender) return undefined - return { sender, contents, type: 'minecraft:chat', displayName } + return { sender, contents, type: 'minecraft:chat' } } function isSeparatorAt (children, start) { - return (children[start]?.text === '»' || children[start]?.text === '\xa79»\xa7r') && children[start + 1]?.text === ' ' + return (children[start]?.text === '»' || children[start]?.text === '\xa79»\xa7r') && children[start + 1]?.text === '' } // [prefix]&r [name] [suffix] &9»&r // {DISPLAYNAME} &9»&r {MESSAGE} @@ -43,5 +53,9 @@ function isSeparatorAt (children, start) { {"extra":[{"text":"e e"},{"text":" "},{"color":"dark_red","text":"Parker"},{"color":"black","text":"2991"},{"text":" "}, {"color":"blue","text":"»"},{"text":" "},{"color":"white","text":"duping fucking rank"}],"text":""} */ +/* +{"extra":[{"bold":true,"color":"dark_red","text":"["},{"bold":true,"color":"red","text":"OP"},{"bold":true,"color":"dark_red","text":"]"}, +{"text":" "},{"color":"red","text":"Parker2991"},{"text":" "},{"color":"blue","text":"»"},{"text":" e"}],"text":""} +*/ module.exports = savage; diff --git a/src/commands/bots.js b/src/commands/bots.js index 19fe633..b8c2aef 100644 --- a/src/commands/bots.js +++ b/src/commands/bots.js @@ -10,7 +10,7 @@ const bots = [ { name: { text: "CddehhBot", color: "red", bold: false }, authors: ["CaydennO1","spyingcreeper09"], - exclaimer: "WHAT IS THIS GOOFY AAAH FUCKING BOT", + exclaimer: "WHAT IS THIS GOOFY AAAH FUCKING BOT FUCKING PIECE OF RETARDED ASS SHIT BOT ITS SO FUCKING SHIT I WANNA IPFILTER IT WITH FUCKING CHOMENS", foundation: "nodejs/mineflayer", prefixes: [","], }, diff --git a/src/commands/discordmsg.js b/src/commands/discordmsg.js index 9705605..831250e 100644 --- a/src/commands/discordmsg.js +++ b/src/commands/discordmsg.js @@ -3,7 +3,7 @@ const CommandError = require("../CommandModules/command_error") module.exports = { name: 'discordmsg', description:['make me say something in discord'], - trustLevel: 0, + trustLevel: -1, aliases:['discordmessage', 'ddmsg'], usage:["message"], execute (context) { diff --git a/src/commands/help.js b/src/commands/help.js index 12a347f..adb4330 100644 --- a/src/commands/help.js +++ b/src/commands/help.js @@ -6,11 +6,12 @@ module.exports = { trustLevel: 0, usage:'[COMMAND]', async execute (context) { - const bot = context.bot - const commandList = [] - const source = context.source - const args = context.arguments - const CommandManager = bot.commandManager + const bot = context.bot; + const commandList = []; + const source = context.source; + const args = context.arguments; + const CommandManager = bot.commandManager; + const config = context.config; const cmd = { translate: '[%s] ', bold: false, @@ -24,11 +25,11 @@ module.exports = { bold: false, color: 'dark_gray', with: [ - { color: `${bot.Commands.colors.help.pub_lickColor}`, text: 'Public'}, + { color: `${config.Commands.colors.help.pub_lickColor}`, text: 'Public'}, { color: 'white', text: ' | '}, - { color: `${bot.Commands.colors.help.t_rustedColor}`, text: 'Trusted'}, + { color: `${config.Commands.colors.help.t_rustedColor}`, text: 'Trusted'}, { color: 'white', text: ' | '}, - { color: `${bot.Commands.colors.help.own_herColor}`, text: 'Owner'}, + { color: `${config.Commands.colors.help.own_herColor}`, text: 'Owner'}, ] } @@ -44,29 +45,29 @@ const command = bot.commandManager.commandlist[commands] valid = true if (bot.options.useChat && !bot.options.isCreayun) { - bot.sendFeedback([{text:`Trust levels: -1 = disabled, 0 = public, 1 = trusted, 2 = owner, 3 = console`,color:`${bot.Commands.colors.help.t_rustedColor}`}]) + bot.sendFeedback([{text:`Trust levels: -1 = disabled, 0 = public, 1 = trusted, 2 = owner, 3 = console`,color:`${config.Commands.colors.help.t_rustedColor}`}]) await bot.chatDelay(100) - bot.sendFeedback({text: `${bot.Commands.prefixes[0]}${command.name} `,color:`${bot.Commands.colors.help.pub_lickColor}`}) + bot.sendFeedback({text: `${config.Commands.prefixes[0]}${command.name} `,color:`${config.Commands.colors.help.pub_lickColor}`}) await bot.chatDelay(100) - bot.sendFeedback({text:`Aliases`,color:`${bot.Commands.colors.help.t_rustedColor}`}) + bot.sendFeedback({text:`Aliases`,color:`${config.Commands.colors.help.t_rustedColor}`}) await bot.chatDelay(100) - bot.sendFeedback({text:`${command.aliases}`,color:`${bot.Commands.colors.help.t_rustedColor}`}) + bot.sendFeedback({text:`${command.aliases}`,color:`${config.Commands.colors.help.t_rustedColor}`}) await bot.chatDelay(100) bot.sendFeedback({text:`${command.description}`}) await bot.chatDelay(100) - bot.sendFeedback([{text:`Trust Level: `,color:`${bot.Commands.colors.help.pub_lickColor}`},{text:`${command.trustLevel}`,color:`${bot.Commands.colors.help.t_rustedColor}`}]) + bot.sendFeedback([{text:`Trust Level: `,color:`${config.Commands.colors.help.pub_lickColor}`},{text:`${command.trustLevel}`,color:`${config.Commands.colors.help.t_rustedColor}`}]) await bot.chatDelay(100) if (command.trustLevel === 2) { await bot.chatDelay(100) - bot.sendFeedback([{text:`Usage: `,color:`${bot.Commands.colors.help.pub_lickColor}`},{text:`${bot.Commands.prefixes[0]}${command.name} `,color:`${bot.Commands.colors.help.t_rustedColor}`},{text:`${command.usage}`,color:`${bot.Commands.colors.help.own_herColor}`}]) + bot.sendFeedback([{text:`Usage: `,color:`${config.Commands.colors.help.pub_lickColor}`},{text:`${bot.Commands.prefixes[0]}${command.name} `,color:`${config.Commands.colors.help.t_rustedColor}`},{text:`${command.usage}`,color:`${config.Commands.colors.help.own_herColor}`}]) await bot.chatDelay(100) } else if (command.trustLevel === 1) { await bot.chatDelay(100) - bot.sendFeedback([{text:`Usage: `,color:`${bot.Commands.colors.help.pub_lickColor}`},{text:`${bot.Commands.prefixes[0]}${command.name} `,color:`${bot.Commands.colors.help.t_rustedColor}`},{text:`${command.usage}`,color:`${bot.Commands.colors.help.own_herColor}`}]) + bot.sendFeedback([{text:`Usage: `,color:`${config.Commands.colors.help.pub_lickColor}`},{text:`${config.Commands.prefixes[0]}${command.name} `,color:`${config.Commands.colors.help.t_rustedColor}`},{text:`${command.usage}`,color:`${config.Commands.colors.help.own_herColor}`}]) await bot.chatDelay(100) } else { await bot.chatDelay(100) - bot.sendFeedback([{text:`Usage: `,color:`${bot.Commands.colors.help.pub_lickTheme}`},{text:`${bot.Commands.prefixes[0]}${command.name} `,color:`${bot.Commands.colors.help.t_rustedColor}`},{text:`${command.usage}`,color:`${bot.Commands.colors.help.own_herColor}`}]) + bot.sendFeedback([{text:`Usage: `,color:`${config.Commands.colors.help.pub_lickTheme}`},{text:`${bot.Commands.prefixes[0]}${command.name} `,color:`${config.Commands.colors.help.t_rustedColor}`},{text:`${command.usage}`,color:`${config.Commands.colors.help.own_herColor}`}]) await bot.chatDelay(100) } @@ -83,38 +84,34 @@ const command = bot.commandManager.commandlist[commands] await bot.chatDelay(2000) if (command.trustLevel === 2) { await bot.chatDelay(2000) - bot.chat(`ඞ${bot.Commands.prefixes[0]}${command.name} ${command.usage}`) + bot.chat(`ඞ${config.Commands.prefixes[0]}${command.name} ${command.usage}`) await bot.chatDelay(2000) } else if (command.trustLevel === 1) { await bot.chatDelay(2000) - bot.chat(`ඞ${bot.Commands.prefixes[0]}${command.name} ${command.usage}`) + bot.chat(`ඞ${config.Commands.prefixes[0]}${command.name} ${command.usage}`) await bot.chatDelay(2000) } else { await bot.chatDelay(2000) - bot.chat(`ඞ${bot.Commands.prefixes[0]}${command.name} ${command.usage}`) + bot.chat(`ඞ${config.Commands.prefixes[0]}${command.name} ${command.usage}`) await bot.chatDelay(2000) } } else { - bot.sendFeedback([cmd,{text:`Trust levels: -1 = disabled, 0 = public, 1 = trusted, 2 = owner, 3 = console`,color:`${bot.Commands.colors.help.t_rustedColor}`}]) - bot.sendFeedback([cmd, {text:`${bot.Commands.prefixes[0]}${command.name} `,color:`${bot.Commands.colors.help.pub_lickColor}`},{text:`(Aliases: ${command.aliases}) › ${command.description}`,color:`${bot.Commands.colors.help.t_rustedColor}`}]) - bot.sendFeedback([cmd,{text:`Trust Level: `,color:`${bot.Commands.colors.help.pub_lickColor}`},{text:`${command.trustLevel}`,color:`${bot.Commands.colors.help.t_rustedColor}`}]) + bot.sendFeedback([cmd,{text:`Trust levels: -1 = disabled, 0 = public, 1 = trusted, 2 = owner, 3 = console`,color:`${config.Commands.colors.help.t_rustedColor}`}]) + bot.sendFeedback([cmd, {text:`${config.Commands.prefixes[0]}${command.name} `,color:`${config.Commands.colors.help.pub_lickColor}`},{text:`(Aliases: ${command.aliases}) › ${command.description}`,color:`${config.Commands.colors.help.t_rustedColor}`}]) + bot.sendFeedback([cmd,{text:`Trust Level: `,color:`${config.Commands.colors.help.pub_lickColor}`},{text:`${command.trustLevel}`,color:`${config.Commands.colors.help.t_rustedColor}`}]) if (command.trustLevel === 2) { - bot.sendFeedback([cmd,{text:`Usage: `,color:`${bot.Commands.colors.help.pub_lickColor}`},{text:`${bot.Commands.prefixes[0]}${command.name} `,color:`${bot.Commands.colors.help.t_rustedColor}`},{text:`${command.usage}`,color:`${bot.Commands.colors.help.own_herColor}`}]) + bot.sendFeedback([cmd,{text:`Usage: `,color:`${config.Commands.colors.help.pub_lickColor}`},{text:`${config.Commands.prefixes[0]}${command.name} `,color:`${config.Commands.colors.help.t_rustedColor}`},{text:`${command.usage}`,color:`${config.Commands.colors.help.own_herColor}`}]) } else if (command.trustLevel === 1) { - bot.sendFeedback([cmd,{text:`Usage: `,color:`${bot.Commands.colors.help.pub_lickColor}`},{text:`${bot.Commands.prefixes[0]}${command.name} `,color:`${bot.Commands.colors.help.t_rustedColor}`},{text:`${command.usage}`,color:`${bot.Commands.colors.help.own_herColor}`}]) + bot.sendFeedback([cmd,{text:`Usage: `,color:`${config.Commands.colors.help.pub_lickColor}`},{text:`${config.Commands.prefixes[0]}${command.name} `,color:`${config.Commands.colors.help.t_rustedColor}`},{text:`${command.usage}`,color:`${config.Commands.colors.help.own_herColor}`}]) } else { - bot.sendFeedback([cmd,{text:`Usage: `,color:`${bot.Commands.colors.help.pub_lickColor}`},{text:`${bot.Commands.prefixes[0]}${command.name} `,color:`${bot.Commands.colors.help.t_rustedColor}`},{text:`${command.usage}`,color:`${bot.Commands.colors.help.own_herColor}`}]) + bot.sendFeedback([cmd,{text:`Usage: `,color:`${config.Commands.colors.help.pub_lickColor}`},{text:`${config.Commands.prefixes[0]}${command.name} `,color:`${config.Commands.colors.help.t_rustedColor}`},{text:`${command.usage}`,color:`${config.Commands.colors.help.own_herColor}`}]) } } -break - // } + break } else valid = false } - - if (valid) { - } else if (!valid) { const args = context.arguments if (bot.options.isCreayun) { @@ -122,7 +119,7 @@ break await bot.chatDelay(1500) bot.chat(bot.getMessageAsPrismarine({ translate: "command.context.here", color: "dark_red" })?.toMotd(bot.registry.language).replaceAll("§","&")) } else { - bot.sendFeedback([cmd, {translate: `Unknown command %s. Type "${bot.Commands.prefixes[0]}help" for help or click on this for the command`,color:'red', with: [args[0]], clickEvent: bot.options.Core.customName ? { action: 'suggest_command', value: `${bot.Commands.prefixes[0]}help` } : undefined}]) + bot.sendFeedback([cmd, {translate: `Unknown command %s. Type "${config.Commands.prefixes[0]}help" for help or click on this for the command`,color:'red', with: [args[0]], clickEvent: bot.options.Core.customName ? { action: 'suggest_command', value: `${config.Commands.prefixes[0]}help` } : undefined}]) } } @@ -175,7 +172,7 @@ break own_her.push( { text: command.name + ' ', - color: `${bot.Commands.colors.help.own_herColor}`, + color: `${config.Commands.colors.help.own_herColor}`, translate:"", @@ -192,7 +189,7 @@ break {text:'click on me to use me :)'}, ] },clickEvent:{ - action:"run_command",value:`${bot.Commands.prefixes[0]}${command.name}` + action:"run_command",value:`${config.Commands.prefixes[0]}${command.name}` }, @@ -208,7 +205,7 @@ break t_rust.push( { text: command.name + ' ', - color:`${bot.Commands.colors.help.t_rustedColor}`, + color:`${config.Commands.colors.help.t_rustedColor}`, translate:"", @@ -224,7 +221,7 @@ break {text:'click on me to use me :)'}, ] },clickEvent:{ - action:"run_command",value:`${bot.Commands.prefixes[0]}${command.name}` + action:"run_command",value:`${config.Commands.prefixes[0]}${command.name}` }, } @@ -256,11 +253,8 @@ break {text:'click on me to use me :)'}, ] },clickEvent:{ - action:"suggest_command",value:`${bot.Commands.prefixes[0]}${command.name}`} - + action:"suggest_command",value:`${config.Commands.prefixes[0]}${command.name}`} }) - - } } else if (command.trustLevel === -1) { disabled.push({ @@ -275,12 +269,11 @@ break const isConsole = context.source.player ? false : true if(source.sources.console && !source.sources.discord) { - + bot.console.info([cmd, 'Commands (', JSON.stringify(CommandManager.commandlist.length), ') ', category, ...pub_lick, t_rust, own_her, cons_ole], false)//[cmd, 'Commands (', length, ') ', category, ...pub_lick, t_rust, own_her, cons_ole] } else if (bot.options.useChat && !bot.options.isCreayun) { - - const length = context.bot.commandManager.commandlist.filter(c => c.trustLevel != 3).length - bot.chat('&8Commands &3(&6' + JSON.stringify(length) + '&3) (&bPublic &f| &5Trusted &f| &4Owner&f)') + const length = context.bot.commandManager.commandlist.filter(c => c.trustLevel != 3).length + bot.chat('&8Commands &3(&6' + JSON.stringify(length) + '&3) (&bPublic &f| &5Trusted &f| &4Owner&f)') await bot.chatDelay(200) bot.chat(`${bot.getMessageAsPrismarine(pub_lick)?.toMotd().replaceAll(',','')}`) await bot.chatDelay(200) @@ -290,7 +283,6 @@ bot.console.info([cmd, 'Commands (', JSON.stringify(CommandManager.commandlist.l } else if (bot.options.isCreayun) { - const length = context.bot.commandManager.commandlist.filter(c => c.trustLevel != 3).length bot.chat('Please note that the bot will not output all commands due the char limit') await bot.chatDelay(1500) @@ -355,9 +347,9 @@ const Embed = new EmbedBuilder() .setDescription(`${command.name} info`) .addFields( // { name: '', value: `${bot.Discord.commandPrefix + command.name}` } - {name: `${bot.Discord.commandPrefix}${command.name} (Aliases: ${command.aliases}) \u203a ${command.description}`, value: `\u200b`,inline:false}, + {name: `${bot.discord.commandPrefix}${command.name} (Aliases: ${command.aliases}) \u203a ${command.description}`, value: `\u200b`,inline:false}, { name: `Trust Level \u203a ${command.trustLevel}`,value:'\u200b'}, - { name: `Usage \u203a ${bot.Discord.commandPrefix}${command.name} ${command.usage}`,value:'\u200b'}, + { name: `Usage \u203a ${bot.discord.commandPrefix}${command.name} ${command.usage}`,value:'\u200b'}, ) bot?.discord?.Message?.reply({embeds: [Embed]}) bot?.discord?.Message.react('♋') @@ -373,7 +365,7 @@ bot?.discord?.Message.react('♋') } else { const args = context.arguments -throw new CommandError(`Unknown command ${args[0]}. type "${bot.Discord.commandPrefix}" for help`) +throw new CommandError(`Unknown command ${args[0]}. type "${bot.discord.commandPrefix}" for help`) } const length = context.bot.commandManager.commandlist.length // ok @@ -422,4 +414,4 @@ throw new CommandError(`Unknown command ${args[0]}. type "${bot.Discord.commandP bot?.discord?.Message.react('♋') } } -} \ No newline at end of file +} diff --git a/src/commands/info.js b/src/commands/info.js index dcf8ded..a67e21c 100644 --- a/src/commands/info.js +++ b/src/commands/info.js @@ -39,11 +39,12 @@ module.exports = { async execute(context) { const bot = context.bot; const args = context.arguments; - const source = context.source + const source = context.source; + const config = context.config; switch(args.join(' ').toLowerCase()) { case 'version': if (bot.options.useChat && !bot.options.isCreayun) { - bot.chat(`${bot.getMessageAsPrismarine({text:`${process.env.buildstring}-${execSync('git rev-parse HEAD').toString().slice(0, 10)}`})?.toMotd().replaceAll('§',"&")}`) + bot.chat(bot.getMessageAsPrismarine({text:`${process.env.buildstring}-${execSync('git rev-parse HEAD').toString().slice(0, 10)}`})?.toMotd().replaceAll('§',"&")) await bot.chatDelay(100) bot.sendFeedback({text:`${process.env.FoundationBuildString}-${execSync('git rev-parse HEAD').toString().slice(0, 10)}`}) await bot.chatDelay(100) @@ -128,19 +129,6 @@ switch(args.join(' ').toLowerCase()) { } break case 'loaded': - let src = fs.readdirSync('./src/').filter(f => path.extname(f).toLowerCase() === '.js').length; - let util = fs.readdirSync('./src/util/').filter(f => path.extname(f).toLowerCase() === '.js').length; - let utilJSON = fs.readdirSync('./src/util/').filter(f => path.extname(f).toLowerCase() === '.json').length; - let language = fs.readdirSync('./src/util/language').filter(f => path.extname(f).toLowerCase() === '.json').length; - let music = fs.readdirSync('./src/util/music').filter(f => path.extname(f).toLowerCase() === '.js').length; - let convertor = fs.readdirSync('./src/util/music/midi_converter').filter(f => path.extname(f).toLowerCase() === '.js').length; - let convertorJSON = fs.readdirSync('./src/util/music/midi_converter').filter(f => path.extname(f).toLowerCase() === '.json').length - let modules = fs.readdirSync('./src/modules').filter(f => path.extname(f).toLowerCase() === '.js').length; - let commands = fs.readdirSync('./src/commands').filter(f => path.extname(f).toLowerCase() === '.js').length; - let chat = fs.readdirSync('./src/chat').filter(f => path.extname(f).toLowerCase() === '.js').length; - let CommandModules = fs.readdirSync('./src/CommandModules').filter(f => path.extname(f).toLowerCase() === '.js').length; - let FileCount = `${src + util + utilJSON + language + music + convertor + convertorJSON + modules + commands + chat + CommandModules}` - // lazy file count :shrug: // source.sendFeedback([{text:'Package Count \u203a ',color:'gray'},{text:`${Object.keys(packageJSON.dependencies).length}`,color:'gold'}]) @@ -149,11 +137,10 @@ switch(args.join(' ').toLowerCase()) { } else if (bot.options.isCreayun) { bot.chat(`Package Count \u203a ${Object.keys(packageJSON.dependencies).length}`) await bot.chatDelay(1500) - bot.chat(`File Could \u203a (${FileCount})`) + bot.chat(`File Could \u203a (${JSON.stringify(FileCount)})`) } else { -// bot.sendFeedback([{text:'Packages \u203a ',color:'gray'},{text:`${Object.entries(packageJSON.dependencies).map((key, value) => key + ' ' + value).join(' ')}`}]) + bot.sendFeedback([{text:'Package Count \u203a ', color:'gray'},{text:`${Object.keys(packageJSON.dependencies).length}`,color:'gold'}]) - bot.sendFeedback([{text:'File count ',color:'gray'},{text:'(',color:'dark_blue'},{text:`${FileCount}`,color:'gold'},{text:')',color:'dark_blue'}]) } break case 'time': @@ -195,7 +182,7 @@ await bot.chatDelay(150) break case 'config': if (bot.options.useChat) { - bot.sendFeedback({text:`Prefixes \u203a ${bot.Commands.prefixes}`,color:'gray'}) + bot.sendFeedback({text:`Prefixes \u203a ${config.Commands.prefixes}`,color:'gray'}) await bot.chatDelay(100) bot.sendFeedback([{text:`Core enabled? `,color:'gray'},{text:`${bot.options.Core.enabled}`,color:'gold'}]) await bot.chatDelay(100) @@ -203,15 +190,15 @@ case 'config': await bot.chatDelay(100) bot.sendFeedback([{text:'Console logging enabled? ',color:'gray'},{text:`${bot.options.Console.enabled}`,color:'gold'}]) await bot.chatDelay(100) - bot.sendFeedback([{text:'Chat filelogging enabled? ',color:'gray'},{text:`${bot.Console.filelogging}`,color:'gold'}]) + bot.sendFeedback([{text:'Chat filelogging enabled? ',color:'gray'},{text:`${config.console.filelogging}`,color:'gold'}]) await bot.chatDelay(100) bot.sendFeedback([{text:'Multiconnect Server count \u203a ',color:'gray'},{text:`${Object.keys(bot.bots).length}`,color:'gold'}]) } else { - bot.sendFeedback({text:`Prefixes \u203a ${bot.Commands.prefixes}`,color:'gray'}) + bot.sendFeedback({text:`Prefixes \u203a ${config.Commands.prefixes}`,color:'gray'}) bot.sendFeedback([{text:`Core enabled? `,color:'gray'},{text:`${bot.options.Core.enabled}`,color:'gold'}]) // bot.sendFeedback([{text:'Discord enabled? ',color:'gray'},{text:`${bot.Discord.enabled}`,color:'gold'}]) bot.sendFeedback([{text:'Console logging enabled? ',color:'gray'},{text:`${bot.options.Console.enabled}`,color:'gold'}]) - bot.sendFeedback([{text:'Chat filelogging enabled? ',color:'gray'},{text:`${bot.Console.filelogging}`,color:'gold'}]) + bot.sendFeedback([{text:'Chat filelogging enabled? ',color:'gray'},{text:`${config.console.filelogging}`,color:'gold'}]) bot.sendFeedback([{text:'Multiconnect Server count \u203a ',color:'gray'},{text:`${Object.keys(bot.bots).length}`,color:'gold'}]) bot.sendFeedback([{text:'Discord enabled? ',color:'gray'},{text:`${bot.Discord.enabled}`,color:'gold'}]) } @@ -268,7 +255,7 @@ const args = context.arguments switch(args.join(' ').toLowerCase()) { case 'version': let Embed = new EmbedBuilder() - .setColor(`${bot.Commands.colors.discord.embed}`) + .setColor(`${configCommands.colors.discord.embed}`) .setTitle(`${this.name} Command`) .setDescription('\u200b') .addFields( @@ -282,7 +269,7 @@ switch(args.join(' ').toLowerCase()) { case 'invites': try { let inviteEmbed = new EmbedBuilder() - .setColor(`${bot.Commands.colors.discord.embed}`) + .setColor(`${config.Commands.colors.discord.embed}`) .setTitle(`${this.name} Command`) .setDescription('Discord Invite ↓↓↓') let inviteButton = new ButtonBuilder() @@ -306,7 +293,7 @@ switch(args.join(' ').toLowerCase()) { case 'loaded': let packages = Object.entries(packageJSON.dependencies).map((key, value) => key + ' ' + value).join(' ') let Embed2 = new EmbedBuilder() - .setColor(`${bot.Commands.colors.discord.embed}`) + .setColor(`${config.Commands.colors.discord.embed}`) .setTitle(`${this.name} Command`) .setDescription('\u200b') .addFields( @@ -316,7 +303,7 @@ switch(args.join(' ').toLowerCase()) { break case 'login': let Embed3 = new EmbedBuilder() - .setColor(`${bot.Commands.colors.discord.embed}`) + .setColor(`${config.Commands.colors.discord.embed}`) .setTitle(`${this.name} Command`) .setDescription(`Server ${bot.options.serverName}\nIP ${bot.options.host}\nVersion ${bot.options.version}\nMinecraft Username ${bot.options.username}\nUUID ${bot._client.uuid}\nDiscord Username ${bot.discord.client.user.username}'#'${bot.discord.client.user.discriminator}\nDiscord Channel ${bot.discord.channel.name}`) @@ -324,21 +311,21 @@ switch(args.join(' ').toLowerCase()) { break case 'config': let Embed4 = new EmbedBuilder() - .setColor(`${bot.Commands.colors.discord.embed}`) + .setColor(`${config.Commands.colors.discord.embed}`) .setTitle(`${this.name} Command`) .setDescription(`Prefixes ${bot.Commands.prefixes}\nCore Enabled? ${bot.options.Core.enabled}\nConsole logging enabled? ${bot.options.Console.enabled}\nChat filelogging enabled? ${bot.Console.filelogging}\nMulticonnect Server count ${(bot.bots).length}`) bot.discord.Message.reply({ embeds: [Embed4] }) break case 'uptime': let Embed5 = new EmbedBuilder() - .setColor(`${bot.Commands.colors.discord.embed}`) + .setColor(`${config.Commands.colors.discord.embed}`) .setTitle(`${this.name} Command`) .setDescription(`${format(process.uptime())}`) bot.discord.Message.reply({ embeds: [Embed5] }) break case 'contributors': let Embed6 = new EmbedBuilder() - .setColor(`${bot.Commands.colors.discord.embed}`) + .setColor(`${config.Commands.colors.discord.embed}`) .setTitle(`${this.name} Command`) .setDescription(`Parker2991\n_ChipMC_\nchayapak\n_yfd\naaa\nMorganAnkan\nTurtleKid`) bot.discord.Message.reply({ embeds: [Embed6] }) @@ -347,4 +334,4 @@ switch(args.join(' ').toLowerCase()) { throw new CommandError(bot.getMessageAsPrismarine({ translate: "command.unknown.argument" })?.toMotd()) } } -} \ No newline at end of file +} diff --git a/src/commands/reload.js b/src/commands/reload.js index 7a65566..14e2d1c 100644 --- a/src/commands/reload.js +++ b/src/commands/reload.js @@ -30,7 +30,7 @@ discordExecute(context) { const source = context.source try { const Embed = new EmbedBuilder() - .setColor('#00FFFF') + .setColor(`${bot.Commands.colors.discord.embed}`) .setTitle(`${this.name} Command`) .setDescription(`reloading crap`) bot.discord.Message.reply({ embeds: [Embed] }) @@ -41,4 +41,4 @@ discordExecute(context) { throw new CommandError(e.stack) } } -} +} \ No newline at end of file diff --git a/src/commands/servereval.js b/src/commands/servereval.js index 45257e6..0e9fa02 100644 --- a/src/commands/servereval.js +++ b/src/commands/servereval.js @@ -37,7 +37,7 @@ module.exports = { let Embed = new EmbedBuilder() .setColor(`${bot.Commands.colors.discord.embed}`) .setTitle(`${this.name} Command`) - .setDescription(util.inspect(eval(args.join(' ')))) + .setDescription(bot.getMessageAsPrismarine('```js\n' + util.inspect(eval(args.join(' '))) + '```')?.toMotd()) bot.discord.Message.reply({ embeds: [Embed] }) } catch (e) { let Embed = new EmbedBuilder() diff --git a/src/commands/theme.js b/src/commands/theme.js index bdba207..a567ae2 100644 --- a/src/commands/theme.js +++ b/src/commands/theme.js @@ -11,9 +11,9 @@ module.exports = { const source = context.source; if (!args && !args[0] && !args[1] && !args[2] && !args[3]) return if (args[0] === undefined || args[1] === undefined || args[2] === undefined) { - bot.Commands.colors.help.pub_lickColor = 'white' - bot.Commands.colors.help.t_rustedColor = 'white' - bot.Commands.colors.help.own_herColor = 'white' + bot.Commands.colors.help.pub_lickColor = '#2b7589' + bot.Commands.colors.help.t_rustedColor = '#219696' + bot.Commands.colors.help.own_herColor = '#2081c3' bot.sendFeedback(`Reseting theme colors,.,.,..`) } else { bot.Commands.colors.help.pub_lickColor = args[0] diff --git a/src/commands/website.js b/src/commands/website.js index 8c39328..36fba93 100644 --- a/src/commands/website.js +++ b/src/commands/website.js @@ -1,5 +1,6 @@ const CommandError = require('../CommandModules/command_error'); const https = require('https'); +const http = require('http'); const util = require('util'); const { EmbedBuilder } = require('discord.js'); module.exports = { @@ -13,6 +14,21 @@ async execute (context) { const source = context.source const args = context.arguments try { + if (args.join(' ').startsWith('http://') && !args.join(' ').startsWith('https://')) { + const options = { + hostname: `${args.join(' ')}` + } +http.request(`${args.join(' ')}`, (res) => { + res.setEncoding('utf8'); + res.on('data', (chunk) => { + //console.log(`BODY: ${chunk}`); + bot.tellraw(chunk) + }); + res.on('end', () => { + console.log('No more data in response.'); + }); +}); + } else if (args.join(' ').startsWith('https://') && !args.join(' ').startsWith('http://')) { https.get(`${args.join(' ')}`, (res) => { res.setEncoding('utf8'); res.on('data', (data) => { @@ -21,9 +37,10 @@ async execute (context) { }).on('error', (e) => { bot.sendError(`${e.toString()}`); }); + } } catch (e) { bot.sendError(`${e.toString()}`) - } + } }, discordExecute (context) { const bot = context.bot; diff --git a/src/index.js b/src/index.js index 16d60f7..23d224a 100644 --- a/src/index.js +++ b/src/index.js @@ -32,22 +32,12 @@ for (const options of config.bots) { bot.bots = bots; bot.Core = core; bot.Commands = commands; - bot.Console = Console; +// bot.Console = Console; bot.discord = discord; bot.validation = validation; bot.savage = savage; bot.options.username; -// createBot(options, bot.core, bot.commands, bot.Console, bot.discord, bot.validation, bot.savage) -// bot.loadModule = (module) => module(bot, options); - loadModules(bot, options); -/*for (const filename of fs.readdirSync(path.join(__dirname, "modules"))) { - try { - const module = require(path.join(__dirname, 'modules', filename)) - bot.loadModule(module); - } catch (error) { - console.error("Failed to load module",filename,":",error); - } - }*/ + loadModules(bot, options, config); } //bot.console.useReadlineInterface(rl); process.on("uncaughtException", (e) => { diff --git a/src/modules/boot.js b/src/modules/boot.js new file mode 100644 index 0000000..c008c3d --- /dev/null +++ b/src/modules/boot.js @@ -0,0 +1,44 @@ +async function boot (bot, options, config) { + bot.on('packet.login', async function (data) { + if (bot.options.isSavage) { + bot.console.warn(`isSavage is enabled for ${bot.options.host}:${bot.options.port} the bot will not be able to run with core`); + await bot.chatDelay(5000); + bot.chat('&5FNF&bBoyfriend&4Bot &f- &4Parker&02991'); + } else if (bot.options.isCreayun) { + bot.console.warn(`isCreayun is enabled for ${bot.options.host}:${bot.options.port} the bot will not be able to run with core`); + } else if (bot.options.isKaboom) { + bot.chat('&5FNF&bBoyfriend&4Bot &f- &4Parker&02991'); + } + if (bot.options.useChat) { + bot.console.warn(`useChat is enabled for ${bot.options.host}:${bot.options.port} the bot will run commands in chat and not core`); + } + }) +} +module.exports = boot; +/* +const timer = setInterval(() => { + if (!config.bots.endcredits) { + return + } else { + bot.chat(`Join the FNFBoyfriendBot discord ${bot.discord.invite}`) + } + }, 280000) + if (bot.options.isCreayun) { + } + var day = new Date().getDay() + if (day === 5) { + bot.chat("Gettin' freaky on a Friday Night!") + } else { + bot.chat(`&5FNF&bBoyfriend&4Bot &f- &4Parker&02991`) + } + timer; + if (bot.options.useChat) { + bot?.console?.warn(`useChat is active for ${bot.options.host} the bot will not be able to run commands in core`) + } else if (bot.options.isCreayun) { +bot?.console?.info(`Creayun mode is active for ${bot.options.host} please not that the bot will not read kaboom commands and messages when Creayun mode is active`) + } + if (bot.options.debug.enabled) { +bot.console.warn(`Debug mode is enabled for ${bot.options.host}:${bot.options.port} please note this WILL spam console is all options are enabled`) + } +clearInterval(timer) +*/ diff --git a/src/modules/chat.js b/src/modules/chat.js index 3109a68..b555a58 100644 --- a/src/modules/chat.js +++ b/src/modules/chat.js @@ -9,7 +9,7 @@ const typeemotetextChatParser = require('../chat/chatTypeEmote') const sayChatParser = require('../chat/say'); const savageChatParser = require('../chat/savage') const { parseMessage } = require('../util/NbtChatParser'); - +const nbt = require('prismarine-nbt'); function tryParse (json) { try { return JSON.parse(json) @@ -25,16 +25,16 @@ function inject (bot) { if (bot.options.isCreayun && !bot.options.isKaboom) { bot.chatParsers = [creayunChatParser]; } else if (bot.options.isSavage) { - bot.chatParsers = [savageChatParser, sayChatParser, creayunChatParser]; + bot.chatParsers = [savageChatParser, sayChatParser, creayunChatParser, chipmunkmodChatParser]; } else if (bot.options.isKaboom && !bot.options.isCreayun) { - bot.chatParsers = [kaboomChatParser, chipmunkmodChatParser, chipmunkmodblackilykatverChatParser, typetextChatParser, typeemotetextChatParser, creayunChatParser] + bot.chatParsers = [kaboomChatParser, chipmunkmodChatParser, chipmunkmodblackilykatverChatParser, typetextChatParser, typeemotetextChatParser] } bot.on('packet.profileless_chat', packet => {//loadPrismarineChat.processNbtMessage(nbt.comp(json)) if (bot.options.version === '1.20.4' || bot.options.version === '1.20.3') { // message = tryParse(loadPrismarineChat.processNbtMessage(packet.message)) - message = parseMessage(tryParse(loadPrismarineChat.processNbtMessage(packet.message))); - sender = parseMessage(tryParse(loadPrismarineChat.processNbtMessage(packet.name))); + message = tryParse(nbt.simplify(packet.message)); + sender = tryParse(nbt.simplify(packet.name)); // sender = tryParse(loadPrismarineChat.processNbtMessage(packet.name)) // console.log(sender) // console.log(message) @@ -80,11 +80,18 @@ function inject (bot) { } else if (bot.options.version === '1.20.4' || bot.options.version === '1.20.3') { // unsigned = tryParse(tryParse(loadPrismarineChat.processNbtMessage(packet.unsignedChatContent))) - unsigned = parseMessage(tryParse(loadPrismarineChat.processNbtMessage(packet.unsignedChatContent))) +// unsigned = parseMessage(tryParse(loadPrismarineChat.processNbtMessage(packet.unsignedChatContent))) +// unsigned = loadPrismarineChat.processNbtMessage(nbt.comp(packet.unsignedChatContent).value) + unsigned = nbt.simplify(packet.unsignedChatContent) +// console.log(packet.signature) + // tryParse(nbt.comp(packet.message)); +// console.log(bot.getMessageAsPrismarine(nbt.comp(unsigned))?.toAnsi()) +// console.log(fromNotch(nbt.comp(msg).value).toAnsi()) +// console.log(bot.getMessageAsPrismarine(unsigned)?.toAnsi()) } if (bot.options.debug.enabled) { - if (bot.options.debug.chat.player.json && bot.options.debug.enabled) bot.console.debug(bot.getMessageAsPrismarine([{text:'[',color:'dark_gray'},{text:'playerChat',color:'dark_green'},{text:'] ',color:'dark_gray'},{text:'[',color:'dark_gray'},{text:'JSON',color:'yellow'},{text:'] ',color:'dark_gray'}])?.toAnsi() + JSON.stringify(unsigned)) + if (bot.options.debug.chat.player.json && bot.options.debug.enabled) bot.console.debug(bot.getMessageAsPrismarine([{text:'[',color:'dark_gray'},{text:'playerChat',color:'dark_green'},{text:'] ',color:'dark_gray'},{text:'[',color:'dark_gray'},{text:'JSON',color:'yellow'},{text:'] ',color:'dark_gray'}])?.toAnsi() + JSON.stringify(packet.unsignedChatContent)) if (bot.options.debug.chat.player.ansi && bot.options.debug.enabled) bot.console.debug(bot.getMessageAsPrismarine([{text:'[',color:'dark_gray'},{text:'playerChat',color:'dark_green'},{text:'] ',color:'dark_gray'},{text:'[',color:'dark_gray'},{text:'Ansi/normal',color:'gold'},{text:'] ',color:'dark_gray'}])?.toAnsi() + bot.getMessageAsPrismarine(tryParse(packet.unsigned))?.toAnsi()) @@ -95,14 +102,14 @@ function inject (bot) { const translateMessage = bot.getMessageAsPrismarine(unsigned)?.toMotd() const translateUsername = bot.getMessageAsPrismarine(packet.sender)?.toMotd() if (packet.type === 5) bot.emit('message', bot.getMessageAsPrismarine({translate:"chat.type.announcement",color:'white', with:[`${translateUsername}`,`${translateMessage}`]})?.toMotd()) - bot.emit('player_chat', { plain: packet.plainMessage, unsigned, senderUuid: packet.senderUuid }) + bot.emit('player_chat', { plain: nbt.simplify(packet.plainMessage), unsigned, senderUuid: packet.senderUuid }) bot.emit('message', unsigned) tryParsingMessage(unsigned, { senderUuid: packet.senderUuid, players: bot.players, getMessageAsPrismarine: bot.getMessageAsPrismarine}) }) bot.getMessageAsPrismarine = message => { try { if (ChatMessage !== undefined) { - return new ChatMessage(message) + return new ChatMessage(nbt.simplify(message)) } } catch (error) { console.error(error); // Log any errors that occur during object creation @@ -139,10 +146,12 @@ function inject (bot) { let parsed for (const parser of bot.chatParsers) { parsed = parser(message, data) +// console.log(parsed) if (parsed) break } if (!parsed) return +// console.log(data) bot.emit('parsed_message', parsed) } @@ -151,7 +160,9 @@ function inject (bot) { if (ChatMessage !== undefined) { return new ChatMessage(message) } - } catch {} + } catch (e) { +// console.log(e) + } return undefined } @@ -190,6 +201,8 @@ function inject (bot) { } bot.tellraw = (message, selector = '@a') => bot.core.run('/minecraft:tellraw @a ' + JSON.stringify(message)) // ? Should this be here? + bot.chatDelay = function delay(ms) { + return new Promise((resolve) => setTimeout(resolve, ms)); + } } - module.exports = inject diff --git a/src/modules/chat_command_handler.js b/src/modules/chat_command_handler.js index 76724a1..59a2d2b 100644 --- a/src/modules/chat_command_handler.js +++ b/src/modules/chat_command_handler.js @@ -1,100 +1,56 @@ const CommandSource = require("../CommandModules/command_source"); const CommandError = require("../CommandModules/command_error"); -//can i change the var? const { execSync } = require('child_process'); -function chat_command_handler(bot) { +function chat_command_handler(bot, options, config) { let ratelimit = 0 bot.on("parsed_message", (data) => { if (data.type !== "minecraft:chat") return; - - const prefixes = bot.Commands.prefixes; - + const prefixes = config.Commands.prefixes; prefixes.map((prefix) => { const plainMessage = bot .getMessageAsPrismarine(data.contents) ?.toString(); if (!plainMessage.startsWith(prefix)) return; - - const command = plainMessage.substring(prefix.length); // if the prefixes are the same length just make it 1 or the length - /* - lifes sus - */ - const source = new CommandSource(data.sender,{ discord: false, console: false }); + const command = plainMessage.substring(prefix.length); + const source = new CommandSource(data.sender, { + discord: false, + console: false + }); bot.sendFeedback = (message) => { - const prefix = { - translate: "%s%s%s ", - bold: false, - color: "dark_gray", - with: [ - { - color: "dark_purple", - text: "FNF", - bold: false, - hoverEvent: { - action: "show_text", - value: `${process.env["buildstring"]}}\n${process.env["FoundationBuildString"]}}`, - }, - clickEvent: bot.options.Core.customName - ? { action: "open_url", value: bot.options.Core.customName } - : undefined, - }, - { - color: "#2FE0E0", - text: "Boyfriend", - bold: false, - clickEvent: bot.options.discord.invite - ? { action: "open_url", value: bot.options.discord.invite } - : undefined, - hoverEvent: { - action: "show_text", - value: `Bot Username: ${bot.username}\nBot UUID: ${bot.uuid}\nServer Host: ${bot.options.host}:${bot.options.port}\nBot Minecraft Java Version: ${bot.options.version}`, - }, - }, - { - color: "#D90003", - text: "Bot", - bold: false, - clickEvent: bot.options.discord.invite - ? { action: "open_url", value: "https://code.chipmunk.land" } - : undefined, - hoverEvent: { - action: "show_text", - value: "§aMan i like frogs - _ChipMC_", - }, - }, //§aMan i like frogs - _ChipMC_ - - { color: "green", text: command.split(" ")[0] }, - ], - }; - if (bot.options.useChat) { - bot.tellraw([message]); - } else { - bot.tellraw(["", message]); + if (bot.options.useChat) { + bot.tellraw([message]); + } else { + bot.tellraw(["", message]); + } + }; + bot.sendError = (message) => { + bot.sendFeedback([{ + text: '', + color: `red` + }, message], false) } - -}; -bot.sendError = (message) => { - bot.sendFeedback([{ text: '', color: `red` }, message], false) -} -try{ - + try { ratelimit++ setTimeout(() => { ratelimit-- }, 1000) - if (ratelimit > bot.Commands.ratelimit) { // ,. - bot.sendFeedback({text:'You are using commands too fast!',color:'dark_red'}) - // this isn't blocking running the command you know that right? - } else { - bot.commandManager.executeString(source, command); - }//oh real - - //can i change the variable name so its name isnt confusing? - }catch(e){ + if (ratelimit > config.Commands.ratelimit) { + bot.sendFeedback({ + text: 'You are using commands too fast!', + color: 'dark_red' + }) + } else { + bot.commandManager.executeString(source, command); + } + } catch (e) { console.log(e.stack) - - }; - }); -})// + }; + }); + }) } module.exports = chat_command_handler; +/* +for (const player of blacklist.players) { + console.log('whos blacklisted?',[player]); +} +*/ diff --git a/src/modules/command_core.js b/src/modules/command_core.js index 2400200..b5ebe46 100644 --- a/src/modules/command_core.js +++ b/src/modules/command_core.js @@ -14,7 +14,7 @@ async function command_core (bot, options) { if (!pos) return - bot.command(`fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} repeating_command_block{CustomName:'${bot.Core.JSON}'} destroy`) + bot.command(`fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} repeating_command_block{CustomName:'${bot.Core.JSON}'} replace`) }, diff --git a/src/modules/command_manager.js b/src/modules/command_manager.js index 0c9b01e..fcb92fc 100644 --- a/src/modules/command_manager.js +++ b/src/modules/command_manager.js @@ -1,159 +1,249 @@ const fs = require("fs"); const path = require("path"); const CommandError = require("../CommandModules/command_error.js"); -const { EmbedBuilder } = require('discord.js') -function command_manager(bot, options) { +const { + EmbedBuilder +} = require('discord.js') + +function command_manager(bot, options, config) { bot.commandManager = { commands: {}, commandlist: [], execute(source, commandName, args, message, options) { - const command = this.getCommand(commandName.toLowerCase()); - const player = source?.player?.profile?.name; - const uuid = source?.player?.uuid; + const command = this.getCommand(commandName.toLowerCase()); + const player = source?.player?.profile?.name; + const uuid = source?.player?.uuid; try { -if (source.sources.console && !source?.sources?.discord) { - if (!command || !command.execute) { -bot.console.warn({text:`Unknown Command ${commandName}. type "${bot.Console.prefix}help" for help`,color:'dark_red'}) -} -} else if (source?.sources?.discord && !source.sources.console) { - if (!command || !command.execute) { - const Embed = new EmbedBuilder() - .setColor(`${bot.Commands.colors.discord.error}`) - .setTitle('Unknown Command') - .setDescription(bot.getMessageAsPrismarine([{ // sus - translate: `command.unknown.command`},{text:'\n'},{text:`${commandName} `},{translate:"command.context.here"}])?.toMotd(bot.registry.language)) - bot.discord.Message.reply({ embeds: [Embed] }) - } -} else if (!source?.sources?.discord && !source.sources.console) { - if (bot.options.isCreayun) { + if (source.sources.console && !source?.sources?.discord) { if (!command || !command.execute) { - throw new CommandError(`Unknown command ${commandName} type "${bot.Commands.prefixes[0]}help" for help`) - } - } else { - if (!command || !command.execute) { // bot.options.command.prefixes[0] - throw new CommandError(bot.getMessageAsPrismarine([{ // sus - translate: `command.unknown.command`},{text:'\n'},{text:`${commandName} `},{translate:"command.context.here"}])?.toMotd(bot.registry.language)); - } - } -} else if (bot.options.isCreayun) { - if (!command || !command.execute) { - bot.chat(`Unknown command ${commandName} type "${bot.Commands.prefixes[0]}help" for help`) - } -} - -const event = bot?.discord?.Message - - const roles = event?.member?.roles?.cache -if (command?.trustLevel === -1) { -throw new CommandError('this command has been disabled!') -} - if (command?.trustLevel > 0) { -if (command?.trustLevel === 1 && !source?.sources?.discord && !source?.sources?.console) { - const hash = `${args[0]}` - -if (args.length === 0 && bot.hash && bot.owner && bot.hashing.hash) throw new CommandError([{text:'Please provide an ',color:'gray'},{text:'Trusted ',color:'#219696'},{text:'hash or an ',color:'gray'},{text:'Owner ',color:'#2081c3'},{text:'hash',color:'gray'}]) -if (hash !== bot.hash && hash !== bot.owner && hash !== bot.hashing.hash) throw new CommandError([{text:'Invalid ',color:'gray'},{text:'Trusted ',color:'#219696'},{text:'hash or Invalid ',color:'gray'},{text:'Owner ',color:'#2081c3'},{text:'hash',color:'gray'}]) - -} else if (command.trustLevel === 1 && source?.sources?.discord && !source.sources.console) { - - - const hasRole = roles?.some(role => role.name === `${bot.validation.discord.roles.trusted}` || role.name === `${bot.validation.discord.roles.owner}`) - - if (!hasRole) throw new CommandError({ translate: 'You are not trusted!' }) - } - bot?.hashing?.updateHash(); - - if (args[0] === bot.hash) { - bot.console.info({ text: `Player ${player} UUID: ${uuid} Hash:${bot.hash}`, color: 'white' }) - } else if (args[0] === bot.owner) { - bot.console.info({ text: `Player ${player} UUID: ${uuid} Hash:${bot.owner}`, color: 'white' }) + bot.console.warn({ + text: `Unknown Command ${commandName}. type "${bot.Console.prefix}help" for help`, + color: 'dark_red' + }) + } + } else if (source?.sources?.discord && !source.sources.console) { + if (!command || !command.execute) { + const Embed = new EmbedBuilder() + .setColor(`${bot.Commands.colors.discord.error}`) + .setTitle('Unknown Command') + .setDescription(bot.getMessageAsPrismarine([{ // sus + translate: `command.unknown.command` + }, { + text: '\n' + }, { + text: `${commandName} ` + }, { + translate: "command.context.here" + }])?.toMotd(bot.registry.language)) + bot.discord.Message.reply({ + embeds: [Embed] + }) + } + } else if (!source?.sources?.discord && !source.sources.console) { + if (bot.options.isCreayun) { + if (!command || !command.execute) { + throw new CommandError(`Unknown command ${commandName} type "${bot.Commands.prefixes[0]}help" for help`) + } + } else { + if (!command || !command.execute) { // bot.options.command.prefixes[0] + throw new CommandError(bot.getMessageAsPrismarine([{ // sus + translate: `command.unknown.command` + }, { + text: '\n' + }, { + text: `${commandName} ` + }, { + translate: "command.context.here" + }])?.toMotd(bot.registry.language)); + } + } + } else if (bot.options.isCreayun) { + if (!command || !command.execute) { + bot.chat(`Unknown command ${commandName} type "${bot.Commands.prefixes[0]}help" for help`) } -if (command?.trustLevel === 2 && !source?.sources?.discord && !source?.sources?.console) { -const owner = `${args[0]}` -if (args.length === 0 && bot.owner) throw new CommandError([{text:'Please provide a ',color:'red',color:'gray'},{text:'Owner ',color:'#2081c3'},{text:'hash',color:'gray'}]) -if (owner === bot.hash || owner === bot.hashing.hash) throw new CommandError([{text:"THATS A ",color:'gray'},{text:'TRUSTED ',color:'#219696'},{text:'HASH AFAIK',color:'gray'}]) -if (owner !== bot.owner) throw new CommandError([{text:"Invalid ",color:'gray'},{text:'Owner ',color:'#2081c3'},{text:'Hash',color:'gray'}]) - -} else if (command?.trustLevel === 2 && source?.sources?.discord && !source?.sources?.console) { - // const events = source.discordMessageEvent - -// const roless = events?.member?.roles?.cache - - const hasRole = roles?.some(role => role.name === `${bot.validation.discord.roles.owner}`) - - if (!hasRole) throw new CommandError({ translate: 'You are not the Owner!' }) - } - if (command.trustLevel === 3 && !source?.sources?.console) - - throw new CommandError({translate: "This command can only be executed via console",color: "blue",}); } - if(source?.sources?.discord && !source?.sources?.matrix && !source.sources.console){ - if (!command?.discordExecute && command) { - bot.discord.Message.reply('This command is not supported in discord!') -}else{ -return command?.discordExecute({bot, source, arguments: args, args}) -} -}else{ - return command?.execute({ bot, source, arguments: args, options }); + const event = bot?.discord?.Message + const roles = event?.member?.roles?.cache + if (command?.trustLevel === -1) { + throw new CommandError('this command has been disabled!') + } + if (command?.trustLevel > 0) { + if (command?.trustLevel === 1 && !source?.sources?.discord && !source?.sources?.console) { + const hash = `${args[0]}` + if (args.length === 0 && bot.hash && bot.owner && bot.hashing.hash) throw new CommandError([{ + text: 'Please provide an ', + color: 'gray' + }, { + text: 'Trusted ', + color: '#219696' + }, { + text: 'hash or an ', + color: 'gray' + }, { + text: 'Owner ', + color: '#2081c3' + }, { + text: 'hash', + color: 'gray' + }]) + if (hash !== bot.hash && hash !== bot.owner && hash !== bot.hashing.hash) throw new CommandError([{ + text: 'Invalid ', + color: 'gray' + }, { + text: 'Trusted ', + color: '#219696' + }, { + text: 'hash or Invalid ', + color: 'gray' + }, { + text: 'Owner ', + color: '#2081c3' + }, { + text: 'hash', + color: 'gray' + }]) + } else if (command.trustLevel === 1 && source?.sources?.discord && !source.sources.console) { + const hasRole = roles?.some(role => role.name === `${bot.validation.discord.roles.trusted}` || role.name === `${bot.validation.discord.roles.owner}`) + if (!hasRole) throw new CommandError({ + translate: 'You are not trusted!' + }) + } + bot?.hashing?.updateHash(); + if (args[0] === bot.hash) { + bot.console.info({ + text: `Player ${player} UUID: ${uuid} Hash:${bot.hash}`, + color: 'white' + }) + } else if (args[0] === bot.owner) { + bot.console.info({ + text: `Player ${player} UUID: ${uuid} Hash:${bot.owner}`, + color: 'white' + }) + } + if (command?.trustLevel === 2 && !source?.sources?.discord && !source?.sources?.console) { + const owner = `${args[0]}` + if (args.length === 0 && bot.owner) throw new CommandError([{ + text: 'Please provide a ', + color: 'red', + color: 'gray' + }, { + text: 'Owner ', + color: '#2081c3' + }, { + text: 'hash', + color: 'gray' + }]) + if (owner === bot.hash || owner === bot.hashing.hash) throw new CommandError([{ + text: "THATS A ", + color: 'gray' + }, { + text: 'TRUSTED ', + color: '#219696' + }, { + text: 'HASH AFAIK', + color: 'gray' + }]) + if (owner !== bot.owner) throw new CommandError([{ + text: "Invalid ", + color: 'gray' + }, { + text: 'Owner ', + color: '#2081c3' + }, { + text: 'Hash', + color: 'gray' + }]) + } else if (command?.trustLevel === 2 && source?.sources?.discord && !source?.sources?.console) { + const hasRole = roles?.some(role => role.name === `${bot.validation.discord.roles.owner}`) + if (!hasRole) throw new CommandError({ + translate: 'You are not the Owner!' + }) + } + if (command.trustLevel === 3 && !source?.sources?.console) + throw new CommandError({ + translate: "This command can only be executed via console", + color: "blue", + }); + } + if (source?.sources?.discord && !source?.sources?.matrix && !source.sources.console) { + if (!command?.discordExecute && command) { + bot.discord.Message.reply('This command is not supported in discord!') + } else { + return command?.discordExecute({ + bot, + source, + arguments: args, + config, + options, + }) + } + } else { + return command?.execute({ + bot, + source, + arguments: args, + options, + config, + }); + } + } catch (error) { + if (!source.sources.discord && !source.sources.console) { + if (bot.options.isCreayun || bot.options.isSavage) { + if (error instanceof CommandError) + bot.chat(bot.getMessageAsPrismarine(error._message)?.toMotd().replaceAll('§', '&')) + else bot.chat(bot.getMessageAsPrismarine({ + translate: 'command.failed', + color: 'dark_red' + })?.toMotd(bot.registry.language).replaceAll('§', '&')) + } else { + if (error instanceof CommandError) + bot.sendError(error._message) + else bot.sendError(bot.getMessageAsPrismarine({ + translate: "command.failed", + color: `${config.Commands.colors.error}`, + hoverEvent: { + action: "show_text", + contents: String(error.stack) + }, + })?.toMotd(bot.registry.language)); + } + bot.console.warn(error.stack) + } else if (source.sources.discord && !source.sources.console) { + const Embed = new EmbedBuilder() + .setColor(`${config.Commands.colors.discord.error}`) + .setTitle(`${command?.name} Command`) + .setDescription(`\`\`\`${error}\`\`\``) + bot.discord.Message.reply({ + embeds: [Embed] + }) + } } -} catch (error) { - if (!source.sources.discord && !source.sources.console) { - if (bot.options.isCreayun) { - if (error instanceof CommandError) - bot.chat(bot.getMessageAsPrismarine(error._message)?.toMotd().replaceAll('§','&')) - else bot.chat(bot.getMessageAsPrismarine({ translate: 'command.failed', color: 'dark_red' })?.toMotd(bot.registry.language).replaceAll('§','&')) - } else { - if (error instanceof CommandError) - bot.sendError(error._message) - else bot.sendError(bot.getMessageAsPrismarine({ - translate: "command.failed", - color: `${bot.Commands.colors.error}`, - hoverEvent: { action: "show_text", contents: String(error.stack) }, - })?.toMotd(bot.registry.language)); - } - bot.console.warn(error.stack) - } else if (source.sources.discord && !source.sources.console) { - const Embed = new EmbedBuilder() - .setColor(`${bot.Commands.colors.discord.error}`) - .setTitle(`${command?.name} Command`) - .setDescription(`\`\`\`${error}\`\`\``) - bot.discord.Message.reply({ embeds: [Embed] }) - } - } -}, + }, executeString(source, command) { const [commandName, ...args] = command.split(" "); - return this.execute(source, commandName, args) - }, - discordExecute(source, command) { - const [commandName, ...args] = command.split(" "); - - if (source?.sources?.discord && !source?.sources?.matrix && !source?.sources?.console) { - return this.discordExecute(source, commandName, args) - } - }, + discordExecute(source, command) { + const [commandName, ...args] = command.split(" "); + if (source?.sources?.discord && !source?.sources?.matrix && !source?.sources?.console) { + return this.discordExecute(source, commandName, args) + } + }, register(command) { this.commands[command.name] = command; - if (command.aliases) { command.aliases.map((a) => (this.commands[a] = command)); } }, - getCommand(name) { return this.commands[name]; }, - getCommands() { return Object.values(this.commands); - }, -}; - // + }, + }; commandlist = []; - for (const filename of fs.readdirSync(path.join(__dirname, "../commands"))) { try { const command = require(path.join(__dirname, "../commands", filename)); diff --git a/src/modules/console.js b/src/modules/console.js index 3692741..63d4bed 100644 --- a/src/modules/console.js +++ b/src/modules/console.js @@ -1,8 +1,6 @@ const CommandSource = require("../CommandModules/command_source"); -//const time = moment().tz('america/chicago').format('hh:mm:ss a'); -//const date = moment().tz('america/chicago').format('MM/DD/YY') -function Console(bot, options, context, source) { +function Console (bot, options, config) { const chat = require('prismarine-chat')(bot.options.version) let ratelimit = 0 bot.console = { @@ -20,7 +18,7 @@ function Console(bot, options, context, source) { ) return; - if (line.startsWith(`${bot.Console.prefix}`)) { + if (line.startsWith(`${config.console.prefix}`)) { return bot.commandManager.executeString( bot.console.source, @@ -32,16 +30,12 @@ function Console(bot, options, context, source) { if (line === ",kill") process.exit(); if (line === ",reconnect") bot._client.end(); - - - if (line.startsWith("")) { if (bot.options.useChat) { - return bot.commandManager.executeString( - bot.console.source, - "echo " + line.substring(0), - ) + bot.console.source, + "echo " + line.substring(0), + ) } else { return bot.commandManager.executeString( bot.console.source, @@ -117,24 +111,20 @@ function Console(bot, options, context, source) { const ansi = bot.getMessageAsPrismarine(message)?.toAnsi(); const string = bot.getMessageAsPrismarine(message)?.toString(); - - // if (!bot.options.Console.input) return; - if (!bot.options.Console.enabled) return; - + if (!options.Console.enabled) return; ratelimit++ setTimeout(() => { ratelimit-- }, 1000) - if (ratelimit > bot.options.Console.ratelimit) { // ,. + if (ratelimit > options.Console.ratelimit) { // ,. bot._client.end("Anti spam :3") -// rl.pause(); } else { bot?.console?.log(`${ansi}`); - if (bot.Console.filelogging) { + if (config.console.filelogging) { bot?.console?.filelogger(`${chat.fromNotch([{text:'<',color:'dark_gray'},{text:`${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} `,color:'dark_purple'},{text:`${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO"})}`,color:'#00FFFF'},{text:' LOGS',color:'gold'},{text:'>',color:'dark_gray'},{text:' [',color:'dark_gray'},{text:`${bot.options.serverName}`,color:'dark_gray'},{text:'] ',color:'dark_gray'}])?.toString()} ${string}`) - }//nothing is logging to the file + } }; }) } diff --git a/src/modules/discord.js b/src/modules/discord.js index ab55303..9ff540f 100644 --- a/src/modules/discord.js +++ b/src/modules/discord.js @@ -1,22 +1,22 @@ // TODO: Maybe move client creation elsewhere -const { escapeMarkdown } = require('../util/escapeMarkdown') -const { Client, GatewayIntentBits,interaction } = require('discord.js') +const { Client, GatewayIntentBits, interaction } = require('discord.js') const { MessageContent, GuildMessages, Guilds } = GatewayIntentBits const CommandSource = require('../CommandModules/command_source') const client = new Client({ intents: [Guilds, GuildMessages, MessageContent] }) const util = require('util') -//client.login(process.env.discordtoken) -function discord (bot, options) { -if (!bot.discord.enabled) return +function discord(bot, options) { + if (!bot.discord.enabled) return client.login(bot.discord.token) if (!options.discord?.channelId) { - bot.discord = { invite: bot.discord?.invite } + bot.discord = { + invite: bot.discord?.invite + } return } -const ChatMessage = require('prismarine-chat')(bot.options.version) + const ChatMessage = require('prismarine-chat')(bot.options.version) bot.discord = { client, channel: undefined, @@ -25,16 +25,18 @@ const ChatMessage = require('prismarine-chat')(bot.options.version) presence: bot.discord.presence, token: bot.discord.token, } -// -if (bot.discord.enabled) return -client.on('ready', (context) => { - bot.discord.channel = client.channels.cache.get(options.discord.channelId) - client.user.setPresence({ - activities: [{ name: `${bot.discord.presence.name}`, type: bot.discord.presence.type }], - status: `${bot.discord.presence.status}` - }); -}) -// I feel like this is a modified version of ChomeNS Bot's discord plugin (the js one ofc) lol - chayapak + + if (bot.discord.enabled) return + client.on('ready', (context) => { + bot.discord.channel = client.channels.cache.get(options.discord.channelId) + client.user.setPresence({ + activities: [{ + name: `${bot.discord.presence.name}`, + type: bot.discord.presence.type + }], + status: `${bot.discord.presence.status}` + }); + }) let discordQueue = [] setInterval(() => { @@ -42,165 +44,152 @@ client.on('ready', (context) => { try { bot?.discord?.channel?.send(`\`\`\`ansi\n${discordQueue.join('\n').substring(0, 1984)}\n\`\`\``) } catch (error) { - //ansi real bot.console.error(error.stack) - - }//im pretty sure the discord code is as old as the discord relay prototypes lmao - //sus + + } discordQueue = [] }, 2000) -//const ansi = bot.getMessageAsPrismarine(message).toAnsi(lang).replaceAll('``\`\`\u200b\ansi\n\`\`\u001b[9', '\u001b[3\n`\`\`') - - function sendDiscordMessage (message) { - discordQueue.push(message) -//bot.core.run(`minecraft:title @a actionbar ${JSON.stringify(message)}`) - } - - - function sendComponent (message) { - const ansi = bot.getMessageAsPrismarine(message)?.toAnsi().replaceAll('```\u001b[9```' + '```\u001b[3```')// I have a function to fix ansi :shrug: - - /* - would it be better to do - ``` - message1 - message2 - message3... - ``` - and not - ``` - message1 - ``` - ```` - message2 - ```` - ```` - message3... - ``` - */ - - try { - if (!bot.options.discord.log) return - sendDiscordMessage(fixansi(ansi.replaceAll('`', '`\u200b'))) - //'```ansi\n' + fixansi(ansi.replaceAll('\u200b').substring(0, 1983)) + '\n```' + function sendDiscordMessage(message) { + discordQueue.push(message) + } + + function sendComponent(message) { + const ansi = bot.getMessageAsPrismarine(message)?.toAnsi().replaceAll('```\u001b[9```' + '```\u001b[3```') + + try { + sendDiscordMessage(fixansi(ansi.replaceAll('`', '`\u200b'))) } catch (e) { - //i was gonna try to get it to debug via console bot.console.error(`Error sending a message to Discord:\n${e.message}`) sendDiscordMessage(e.message) -//already tried ansi - }//send isnt defined - } + } + } bot.on('message', message => { sendComponent(message) }) - function messageCreate (message, source) { + function messageCreate(message, source) { bot.discord.Message = message if (message.author.id === bot.discord.client.user.id) return if (message.channel.id !== bot.discord.channel.id) return -// + if (message.content.startsWith(bot.discord.commandPrefix)) { // TODO: Don't hardcode this - const source = new CommandSource({ profile: { name: message?.member?.displayName } }, { discord: true, console: false }, false, message) - - bot.sendFeedback = message => { + const source = new CommandSource({ + profile: { + name: message?.member?.displayName + } + }, { + discord: true, + console: false + }, false, message) + + bot.sendFeedback = message => { sendComponent(message) - //console.log(message.content) } bot.commandManager.executeString(source, message.content.substring(bot.discord.commandPrefix.length)) return } -if(!bot.options.discord.log) return -if(bot.options.useChat){ - bot.chat(`&8[&5FNF&bBoyfriend&4Bot &9Discord&8] ${message.member.displayName.replaceAll('\xa7', '&')}&f › ${message.content.replaceAll('\xa7', '&')}`) -} else { - -const tag = { - translate: '[%s] %s \u203a %s', - with: [ - { - translate: '%s%s%s %s', - bold:false, - with: [ - { - text: 'FNF', - bold: false, - color: 'dark_purple' - }, - { - text: 'Boyfriend', - bold: false, - color: 'aqua' - }, - { - text: 'Bot', - bold: false, - color: 'dark_red' - }, - - { - text: 'Discord', - bold: false, - color: 'blue' - } - ], - clickEvent: bot.discord.invite ? { action: 'open_url', value: bot.discord.invite } : undefined, - hoverEvent: { action: 'show_text', contents: 'Click to join the discord' } - }, - { text: message?.member?.displayName }, - message.content - - ] - } - - if (message.attachments.size > 0) { - message.attachments.forEach(Attachment => { - bot.tellraw([tag, { text:' ' ? ' [Attachment] ' : ' [Attachment] ', hoverEvent: { action: 'show_text', contents: 'Click here to view attachment' }, clickEvent: { action: 'open_url', value: `${Attachment.url}` } }]) - }) + if (bot.options.useChat) { + bot.chat(`&8[&5FNF&bBoyfriend&4Bot &9Discord&8] ${message.member.displayName.replaceAll('\xa7', '&')}&f › ${message.content.replaceAll('\xa7', '&')}`) } else { + + const tag = { + translate: '[%s] %s \u203a %s', + with: [{ + translate: '%s%s%s %s', + bold: false, + with: [{ + text: 'FNF', + bold: false, + color: 'dark_purple' + }, + { + text: 'Boyfriend', + bold: false, + color: 'aqua' + }, + { + text: 'Bot', + bold: false, + color: 'dark_red' + }, + + { + text: 'Discord', + bold: false, + color: 'blue' + } + ], + clickEvent: bot.discord.invite ? { + action: 'open_url', + value: bot.discord.invite + } : undefined, + hoverEvent: { + action: 'show_text', + contents: 'Click to join the discord' + } + }, + { + text: message?.member?.displayName + }, + message.content + + ] + } + + if (message.attachments.size > 0) { + message.attachments.forEach(Attachment => { + bot.tellraw([tag, { + text: ' ' ? ' [Attachment] ' : ' [Attachment] ', + hoverEvent: { + action: 'show_text', + contents: 'Click here to view attachment' + }, + clickEvent: { + action: 'open_url', + value: `${Attachment.url}` + } + }]) + }) + } else { bot.tellraw(tag); - } - } -} - client.on('messageCreate', messageCreate) - - - // - - - process.on("uncaughtException", (e) => { -// sendDiscordMessage("uncaught " + e.stack); - }); - - -function fixansi(message) { - const ansilist = { - "\x1B\[93m": "\x1B[33m", // Yellow - "\x1B\[96m": "\x1B[36m", // Blue - "\x1B\[94m": "\x1B[34m", // Discord Blue - "\x1B\[90m": "\x1B[30m", // Gray - "\x1B\[91m": "\x1B[31m", // Light Red - "\x1B\[95m": "\x1B\[35m", // Pink - "\x1B\[92m": "\x1B\[32m", // Green - "\x1B\[0m": "\x1B\[0m\x1B\[37m", // White - "\x1B\[97m": "\x1B\[0m\x1B\[37m", // White - }; - let i = message; - - for (const ansi in ansilist) { - if (ansilist.hasOwnProperty(ansi)) { - i = i.replace(new RegExp(escapeRegExpChars(ansi), 'g'), ansilist[ansi]); - - function escapeRegExpChars(text) { - return text.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); } } } + client.on('messageCreate', messageCreate) - return i; + process.on("uncaughtException", (e) => { + // sendDiscordMessage("uncaught " + e.stack); + }); + + + function fixansi(message) { + const ansilist = { + "\x1B\[93m": "\x1B[33m", // Yellow + "\x1B\[96m": "\x1B[36m", // Blue + "\x1B\[94m": "\x1B[34m", // Discord Blue + "\x1B\[90m": "\x1B[30m", // Gray + "\x1B\[91m": "\x1B[31m", // Light Red + "\x1B\[95m": "\x1B\[35m", // Pink + "\x1B\[92m": "\x1B\[32m", // Green + "\x1B\[0m": "\x1B\[0m\x1B\[37m", // White + "\x1B\[97m": "\x1B\[0m\x1B\[37m", // White + }; + let i = message; + + for (const ansi in ansilist) { + if (ansilist.hasOwnProperty(ansi)) { + i = i.replace(new RegExp(escapeRegExpChars(ansi), 'g'), ansilist[ansi]); + + function escapeRegExpChars(text) { + return text.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'); + } + } + } + + return i; + } } -} -// -module.exports = discord +module.exports = discord; \ No newline at end of file diff --git a/src/modules/logger.js b/src/modules/logger.js index 9189339..4c7fbc1 100644 --- a/src/modules/logger.js +++ b/src/modules/logger.js @@ -2,7 +2,7 @@ const fs = require("fs"); const path = require("path"); const { createGzip } = require("zlib"); -function consolefilelogger(bot, options, message) { +function consolefilelogger(bot, options, config, message) { const currentDate = new Date(); const timestamp = `${currentDate.getFullYear()}-${(currentDate.getMonth() + 1) .toString() @@ -15,7 +15,7 @@ function consolefilelogger(bot, options, message) { fs.mkdirSync(path.join(__dirname, "../../logs")) } - if (!bot.Console.filelogging) return; + if (!config.console.filelogging) return; try { if (!fs.existsSync(logFolder)) { @@ -26,7 +26,7 @@ function consolefilelogger(bot, options, message) { } function compressFile(input, output) { - if (!bot.Console.filelogging) return + if (!config.console.filelogging) return const plainOutput = output.slice(0, -3); fs.renameSync(input, plainOutput); @@ -59,7 +59,7 @@ function consolefilelogger(bot, options, message) { } console?.info( - `File logging: ${bot.Console.filelogging ? "enabled" : "disabled"}` + `File logging: ${config.console.filelogging ? "enabled" : "disabled"}` ); if (!bot.Console.filelogging) return; // instead of using bot why not just use options cause you already defined it diff --git a/src/modules/reconnect.js b/src/modules/reconnect.js index 9dbfe3d..b959dc5 100644 --- a/src/modules/reconnect.js +++ b/src/modules/reconnect.js @@ -6,7 +6,7 @@ function reconnect (bot, options) { bot.on('end', (reason) => { if (bot.reconnectDelay < 0) return setTimeout(() => { - if (bot.options.usernameGen) { + if (options.usernameGen) { bot._client.end() // bot.options.username = usernameGen() client = options.client ?? mc.createClient(options, bot.options.username = usernameGen(), options.selfcare) @@ -14,8 +14,8 @@ function reconnect (bot, options) { client = options.client ?? mc.createClient(options, options.selfcare) } bot._client = client - bot.console.info(`Reconnecting to ${bot.options.host}:${bot.options.port}`) - bot?.discord?.channel?.send('Reconnecting to `' + bot.options.host + ':' + bot.options.port + '`') + bot.console.info(`Reconnecting to ${options.host}:${options.port}`) + bot?.discord?.channel?.send('Reconnecting to `' + options.host + ':' + options.port + '`') bot.emit('init_client', client) }, bot.reconnectDelay) bot.emit('reconnect', bot._client.end()) diff --git a/src/modules/reload.js b/src/modules/reload.js index 184f7ee..5a399ab 100644 --- a/src/modules/reload.js +++ b/src/modules/reload.js @@ -8,6 +8,8 @@ function reload (bot,options,context) { try { // const command = require(path.join(__dirname, "../commands", filename)); delete require.cache[require.resolve(path.join(__dirname,"../commands",filename))] + // delete require.cache[require.resolve('../../filter.json')] +// const filter = require('../../filter.json'); const command = require(path.join(__dirname, "../commands", filename)); bot.commandManager.register(command); bot.commandManager.commandlist.pop(command) diff --git a/src/modules/selfcare.js b/src/modules/selfcare.js index 3c0cf1a..d219723 100644 --- a/src/modules/selfcare.js +++ b/src/modules/selfcare.js @@ -1,4 +1,4 @@ -const util = require('util') +const util = require('util'); const COMMANDSPY_ENABLED_MESSAGE = { text: 'Successfully enabled CommandSpy' } const COMMANDSPY_DISABLED_MESSAGE = { text: 'Successfully disabled CommandSpy' } @@ -22,6 +22,7 @@ function selfcare (bot) { let tptoggle = false; let jail = false; let creayunJoin = false; +// console.log(config.Commands); bot.on('message', (message, data) => { ansiMessage = bot.getMessageAsPrismarine(message)?.toAnsi() stringmessage = bot.getMessageAsPrismarine(message)?.toString() @@ -33,11 +34,12 @@ function selfcare (bot) { else if (stringmessage === `Vanish for ${bot.options.username}: disabled`) vanished = false; // savage prefix selfcare - else if (JSON.stringify(message) === `{"extra":[{"bold":true,"color":"aqua","text":" > "},{"color":"white","text":"Prefix for user "},{"color":"aqua","text":"${bot.options.username}"},{"color":"white","text":" "},{"color":"green","text":"set to"},{"color":"white","text":": "},{"color":"dark_gray","text":"["},{"color":"aqua","text":"Prefix"},{"color":"dark_gray","text":": "},{"color":"dark_red","text":"${bot.Commands.prefixes[0]}"},{"color":"dark_gray","text":"]"}],"text":""}`) prefix = true + else if (JSON.stringify(message) === `{"extra":[{"bold":true,"color":"aqua","text":" > "},{"color":"white","text":"Prefix for user "},{"color":"aqua","text":"${bot.options.username}"},{"color":"white","text":" "},{"color":"green","text":"set to"},{"color":"white","text":": "},{"color":"dark_gray","text":"["},{"color":"aqua","text":"Prefix"},{"color":"dark_gray","text":": "},{"color":"dark_red","text":"${bot.Commands?.prefixes[0]}"},{"color":"dark_gray","text":"]"}],"text":""}`) prefix = true + //else if (stringmessage === `> Prefix for user ${bot.options.username} set to: [Prefix: ~]`) prefix = true - else if (stringmessage === 'Prefix for user ${bot.options.username} removed.') prefix = false + else if (stringmessage === '> Prefix for user ${bot.options.username} removed.') prefix = false - 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?.startsWith(`> Prefix for user ${bot.options.username} set to: `) || stringmessage === `> Prefix for user ${bot.options.username} removed.`) prefix = false // savage login selfcare else if (stringmessage === 'Please, register to the server with the command: /register ') register = false; @@ -50,9 +52,11 @@ function selfcare (bot) { else if (stringmessage === 'Successful login!') login = true; - else if (stringmessage === "You're already logged in!") login = true; + else if (stringmessage === "You're already logged in!") login = true; - else if (stringmessage === "You're already logged in!") registry = true; + else if (stringmessage === "You\'re already logged in!") register = true; + + else if (stringmessage === "You already have registered this username!") registry = true // You're already logged in! } // Please, register to the server with the command: /register // Please, login with the command: /login @@ -71,13 +75,13 @@ function selfcare (bot) { else if (stringmessage?.startsWith('Welcome ') || stringmessage === 'Welcome to survivayun!') creayunJoin = false - if (stringmessage === `Your prefix has been set to: [Prefix: ~]` || stringmessage === 'Something went wrong while saving the prefix. Please check console.' || stringmessage === 'Unknown command. Type /help for help' || stringmessage === '[SuffEx] Your prefix has been set to: [Prefix: ~]' || stringmessage === 'Unknown command. Type /help for help.') { + if (stringmessage === `Your prefix has been set to: [Prefix: ${bot.Commands?.prefixes[0]}]` || stringmessage === 'Something went wrong while saving the prefix. Please check console.' || stringmessage === 'Unknown command. Type /help for help' || stringmessage === '[SuffEx] Your prefix has been set to: [Prefix: ~]' || stringmessage === 'Unknown command. Type /help for help.') { prefix = true return } // creayun prefix selfcare - else if (stringmessage?.startsWith("Your prefix has been set to: ") || stringmessage.startsWith('[SuffEx] Your prefix has been set to: ') || stringmessage === '[SuffEx] Your prefix has been reset' || stringmessage === "Your prefix has been reset.") prefix = false + else if (stringmessage?.startsWith("Your prefix has been set to: ") || stringmessage?.startsWith('[SuffEx] Your prefix has been set to: ') || stringmessage === '[SuffEx] Your prefix has been reset' || stringmessage === "Your prefix has been reset.") prefix = false else if (stringmessage === 'You no longer have a nickname.' || stringmessage === '[SuffEx] Your nick has been reset!') { nickname = false @@ -85,7 +89,7 @@ function selfcare (bot) { } // creayun nick selfcare - else if (stringmessage?.startsWith("Your nick has been set to: ") || stringmessage.startsWith("[SuffEx] Your nick has been set to: ")) nickname = true + else if (stringmessage?.startsWith("Your nick has been set to: ") || stringmessage?.startsWith("[SuffEx] Your nick has been set to: ")) nickname = true // creayun vanish selfcare else if (stringmessage === "You are now completely invisible to normal users, and hidden from in-game commands." || stringmessage === "You do not have access to that command." || stringmessage === "Unknown command. Type /help for help.") { @@ -116,13 +120,13 @@ function selfcare (bot) { else if (JSON.stringify(message) === '{"text":"Successfully disabled CommandSpy"}') commandSpyEnabled = false // kaboom prefix selfcare - else if (JSON.stringify(message) === `{"extra":[{"text":"&8[&bPrefix: &4${bot.Commands.prefixes[0]}&8]"}],"text":"You now have the tag: "}` || stringmessage === 'Something went wrong while saving the prefix. Please check console.') { + else if (JSON.stringify(message) === `{"extra":[{"text":"&8[&bPrefix: &4${bot.Commands?.prefixes[0]}&8]"}],"text":"You now have the tag: "}` || stringmessage === 'Something went wrong while saving the prefix. Please check console.') { prefix = true return } else if (stringmessage?.startsWith("You now have the tag: ") || JSON?.stringify(message) === '{"text":"You no longer have a tag"}') prefix = false - + // kaboom skin selfcare else if (JSON.stringify(message) === `{"extra":[{"text":"Parker2991"},{"text":"'s"}],"text":"Successfully set your skin to "}` || JSON.stringify(message) === `{"text":"A player with that username doesn't exist"}`) { skin = true @@ -137,7 +141,7 @@ function selfcare (bot) { else if (stringmessage === 'Jails/Unjails a player, TPs them to the jail specified.') jail = true - else if(stringmessage === `You have been jailed!`){ + else if (stringmessage === `You have been jailed!`) { jail = false return } @@ -211,10 +215,10 @@ function selfcare (bot) { else if (!vanished && bot.options.selfcare.vanished) bot.core.run(`/essentials:vanish ${bot.username} enable`); - else if (!prefix && bot.options.selfcare.prefix) bot.command(`rank ${bot.options.username} &8[&bPrefix&8: &4${bot.Commands.prefixes[0]}&8]`); + else if (!prefix && bot.options.selfcare.prefix) bot.command(`rank ${bot.options.username} &8[&bPrefix&8: &4${bot.Commands?.prefixes[0]}&8]`); } else if (bot.options.isCreayun) { if (!creayunJoin) bot.command(`server creative`) - else if (!prefix && bot.options.selfcare.prefix) bot.command(`prefix &8[&bPrefix: &4${bot.Commands.prefixes[0]}&8]`) + else if (!prefix && bot.options.selfcare.prefix) bot.command(`prefix &8[&bPrefix: &4${bot.Commands?.prefixes[0]}&8]`) else if (!nickname && bot.options.selfcare.nickname) bot.command(`nick off`) @@ -230,7 +234,7 @@ function selfcare (bot) { else if (unmuted && bot.options.selfcare.unmuted) bot.core.run(`/essentials:mute ${bot.uuid}`) - else if (!prefix && bot.options.selfcare.prefix) bot.command(`prefix &8[&bPrefix: &4${bot.Commands.prefixes[0]}&8]`) + else if (!prefix && bot.options.selfcare.prefix) bot.command(`prefix &8[&bPrefix: &4${bot.Commands?.prefixes[0]}&8]`) else if (gameMode !== 1 && bot.options.selfcare.gmc) bot.command('gamemode creative @s[type=player]') diff --git a/src/util/loadModules.js b/src/util/loadModules.js index c10b789..259493d 100644 --- a/src/util/loadModules.js +++ b/src/util/loadModules.js @@ -6,11 +6,11 @@ const rl = readline.createInterface({ output: process.stdout, }); -function loadModules (bot, options) { +function loadModules (bot, options, config) { for (const filename of fs.readdirSync(path.join(__dirname, "../modules"))) { try { const module = require(path.join(__dirname, '../modules', filename)) - bot.loadModule = (module) => module(bot, options); + bot.loadModule = (module) => module(bot, options, config); bot.loadModule(module); } catch (error) { console.error("Failed to load module", filename, ":", error); diff --git a/src/util/usernameGen.js b/src/util/usernameGen.js index d82efc6..947a534 100644 --- a/src/util/usernameGen.js +++ b/src/util/usernameGen.js @@ -1,10 +1,10 @@ function usernameGen () { const characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'; let username = ''; - for (let i = 0; i < 9; i++ ) { + for (let i = 0; i < 10; i++ ) { const randomIndex = Math.floor(Math.random() * characters.length); username += characters[randomIndex]; } return username; } -module.exports = usernameGen +module.exports = usernameGen;