mirror of
https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot.git
synced 2024-11-21 10:18:21 -05:00
improved how disconnects are logged.
removed reload since i basically dont ever use it. removed xml for the same reason as reload. added es6 support for commands only. added back chat_command_handler.js moved checks to src/util/checks.js v6.0.7 build: 1080
This commit is contained in:
parent
831fda8607
commit
0aed4d7d7a
21 changed files with 444 additions and 278 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -6,4 +6,5 @@ logs/*
|
|||
src/data/filter.json
|
||||
data/filter.json
|
||||
prototyping-crap
|
||||
|
||||
src/data/trustedPlayers.js
|
||||
data/trustedPlayers.js
|
||||
|
|
234
package-lock.json
generated
234
package-lock.json
generated
|
@ -5,6 +5,7 @@
|
|||
"packages": {
|
||||
"": {
|
||||
"dependencies": {
|
||||
"color-convert": "^2.0.1",
|
||||
"cowsay": "^1.6.0",
|
||||
"cowsay2": "^2.0.4",
|
||||
"discord.js": "^14.16.3",
|
||||
|
@ -21,6 +22,7 @@
|
|||
"prismarine-auth": "^2.2.0",
|
||||
"prismarine-chat": "^1.10.1",
|
||||
"prismarine-registry": "^1.7.0",
|
||||
"proxy-agent": "^6.4.0",
|
||||
"wikipedia": "^2.1.2",
|
||||
"xml2js": "^0.6.2"
|
||||
}
|
||||
|
@ -460,6 +462,12 @@
|
|||
"npm": ">=7.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@tootallnate/quickjs-emscripten": {
|
||||
"version": "0.23.0",
|
||||
"resolved": "https://registry.npmjs.org/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz",
|
||||
"integrity": "sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.1.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.1.3.tgz",
|
||||
|
@ -604,6 +612,18 @@
|
|||
"resolved": "https://registry.npmjs.org/asn1/-/asn1-0.2.3.tgz",
|
||||
"integrity": "sha512-6i37w/+EhlWlGUJff3T/Q8u1RGmP5wgbiwYnOnbOqvtrPxT63/sYFyP9RcpxtxGymtfA075IvmOnL7ycNOWl3w=="
|
||||
},
|
||||
"node_modules/ast-types": {
|
||||
"version": "0.13.4",
|
||||
"resolved": "https://registry.npmjs.org/ast-types/-/ast-types-0.13.4.tgz",
|
||||
"integrity": "sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"tslib": "^2.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/asynckit": {
|
||||
"version": "0.4.0",
|
||||
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
|
||||
|
@ -641,6 +661,15 @@
|
|||
}
|
||||
]
|
||||
},
|
||||
"node_modules/basic-ftp": {
|
||||
"version": "5.0.5",
|
||||
"resolved": "https://registry.npmjs.org/basic-ftp/-/basic-ftp-5.0.5.tgz",
|
||||
"integrity": "sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/binary-parser": {
|
||||
"version": "1.9.2",
|
||||
"resolved": "https://registry.npmjs.org/binary-parser/-/binary-parser-1.9.2.tgz",
|
||||
|
@ -821,6 +850,7 @@
|
|||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
|
||||
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"color-name": "~1.1.4"
|
||||
},
|
||||
|
@ -952,6 +982,15 @@
|
|||
"node": ">= 8"
|
||||
}
|
||||
},
|
||||
"node_modules/data-uri-to-buffer": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz",
|
||||
"integrity": "sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
|
@ -976,6 +1015,20 @@
|
|||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/degenerator": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/degenerator/-/degenerator-5.0.1.tgz",
|
||||
"integrity": "sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ast-types": "^0.13.4",
|
||||
"escodegen": "^2.1.0",
|
||||
"esprima": "^4.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/delayed-stream": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
|
||||
|
@ -1064,6 +1117,58 @@
|
|||
"resolved": "https://registry.npmjs.org/err-code/-/err-code-2.0.3.tgz",
|
||||
"integrity": "sha512-2bmlRpNKBxT/CRmPOlyISQpNj+qSeYvcym/uT0Jx2bMOlKLtSy1ZmLuVxSEKKyor/N5yhvp/ZiG1oE3DEYMSFA=="
|
||||
},
|
||||
"node_modules/escodegen": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/escodegen/-/escodegen-2.1.0.tgz",
|
||||
"integrity": "sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w==",
|
||||
"license": "BSD-2-Clause",
|
||||
"dependencies": {
|
||||
"esprima": "^4.0.1",
|
||||
"estraverse": "^5.2.0",
|
||||
"esutils": "^2.0.2"
|
||||
},
|
||||
"bin": {
|
||||
"escodegen": "bin/escodegen.js",
|
||||
"esgenerate": "bin/esgenerate.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"source-map": "~0.6.1"
|
||||
}
|
||||
},
|
||||
"node_modules/esprima": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
|
||||
"integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
|
||||
"license": "BSD-2-Clause",
|
||||
"bin": {
|
||||
"esparse": "bin/esparse.js",
|
||||
"esvalidate": "bin/esvalidate.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
}
|
||||
},
|
||||
"node_modules/estraverse": {
|
||||
"version": "5.3.0",
|
||||
"resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz",
|
||||
"integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/esutils": {
|
||||
"version": "2.0.3",
|
||||
"resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz",
|
||||
"integrity": "sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/event-target-shim": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz",
|
||||
|
@ -1159,6 +1264,20 @@
|
|||
"node": ">= 6"
|
||||
}
|
||||
},
|
||||
"node_modules/fs-extra": {
|
||||
"version": "11.2.0",
|
||||
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-11.2.0.tgz",
|
||||
"integrity": "sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"graceful-fs": "^4.2.0",
|
||||
"jsonfile": "^6.0.1",
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.14"
|
||||
}
|
||||
},
|
||||
"node_modules/fs-minipass": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-3.0.3.tgz",
|
||||
|
@ -1189,6 +1308,21 @@
|
|||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/get-uri": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/get-uri/-/get-uri-6.0.3.tgz",
|
||||
"integrity": "sha512-BzUrJBS9EcUb4cFol8r4W3v1cPsSyajLSthNkz5BxbpDcHN5tIrM10E2eNvfnvBn3DaT3DUgx0OpsBKkaOpanw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"basic-ftp": "^5.0.2",
|
||||
"data-uri-to-buffer": "^6.0.2",
|
||||
"debug": "^4.3.4",
|
||||
"fs-extra": "^11.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/glob": {
|
||||
"version": "10.4.5",
|
||||
"resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz",
|
||||
|
@ -1432,6 +1566,18 @@
|
|||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/jsonfile": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.1.0.tgz",
|
||||
"integrity": "sha512-5dgndWOriYSm5cnYaJNhalLNDKOqFwyDB/rr1E9ZsGciGvKPs8R2xYGCacuf3z6K1YKDz182fd+fY3cn3pMqXQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"universalify": "^2.0.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"graceful-fs": "^4.1.6"
|
||||
}
|
||||
},
|
||||
"node_modules/jsonwebtoken": {
|
||||
"version": "9.0.2",
|
||||
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz",
|
||||
|
@ -1873,6 +2019,15 @@
|
|||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/netmask": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/netmask/-/netmask-2.0.2.tgz",
|
||||
"integrity": "sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.6.11",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.11.tgz",
|
||||
|
@ -1984,6 +2139,38 @@
|
|||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/pac-proxy-agent": {
|
||||
"version": "7.0.2",
|
||||
"resolved": "https://registry.npmjs.org/pac-proxy-agent/-/pac-proxy-agent-7.0.2.tgz",
|
||||
"integrity": "sha512-BFi3vZnO9X5Qt6NRz7ZOaPja3ic0PhlsmCRYLOpN11+mWBCR6XJDqW5RF3j8jm4WGGQZtBA+bTfxYzeKW73eHg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@tootallnate/quickjs-emscripten": "^0.23.0",
|
||||
"agent-base": "^7.0.2",
|
||||
"debug": "^4.3.4",
|
||||
"get-uri": "^6.0.1",
|
||||
"http-proxy-agent": "^7.0.0",
|
||||
"https-proxy-agent": "^7.0.5",
|
||||
"pac-resolver": "^7.0.1",
|
||||
"socks-proxy-agent": "^8.0.4"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/pac-resolver": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/pac-resolver/-/pac-resolver-7.0.1.tgz",
|
||||
"integrity": "sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"degenerator": "^5.0.0",
|
||||
"netmask": "^2.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/package-json-from-dist": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.0.tgz",
|
||||
|
@ -2131,6 +2318,34 @@
|
|||
"protodef-validator": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-agent": {
|
||||
"version": "6.4.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-agent/-/proxy-agent-6.4.0.tgz",
|
||||
"integrity": "sha512-u0piLU+nCOHMgGjRbimiXmA9kM/L9EHh3zL81xCdp7m+Y2pHIsnmbdDoEDoAz5geaonNR6q6+yOPQs6n4T6sBQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"agent-base": "^7.0.2",
|
||||
"debug": "^4.3.4",
|
||||
"http-proxy-agent": "^7.0.1",
|
||||
"https-proxy-agent": "^7.0.3",
|
||||
"lru-cache": "^7.14.1",
|
||||
"pac-proxy-agent": "^7.0.1",
|
||||
"proxy-from-env": "^1.1.0",
|
||||
"socks-proxy-agent": "^8.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-agent/node_modules/lru-cache": {
|
||||
"version": "7.18.3",
|
||||
"resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-7.18.3.tgz",
|
||||
"integrity": "sha512-jumlc0BIUrS3qJGgIkWZsyfAM7NCWiBcCDhnd+3NNM5KbBmLTgHVfWBcg6W+rLUsIpzpERPsvwUP7CckAQSOoA==",
|
||||
"license": "ISC",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
}
|
||||
},
|
||||
"node_modules/proxy-from-env": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
|
||||
|
@ -2292,6 +2507,16 @@
|
|||
"node": ">= 14"
|
||||
}
|
||||
},
|
||||
"node_modules/source-map": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
|
||||
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
|
||||
"license": "BSD-3-Clause",
|
||||
"optional": true,
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/sprintf-js": {
|
||||
"version": "1.1.3",
|
||||
"resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.1.3.tgz",
|
||||
|
@ -2458,6 +2683,15 @@
|
|||
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/universalify": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",
|
||||
"integrity": "sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">= 10.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/uri-js": {
|
||||
"version": "4.4.1",
|
||||
"resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"dependencies": {
|
||||
"color-convert": "^2.0.1",
|
||||
"cowsay": "^1.6.0",
|
||||
"cowsay2": "^2.0.4",
|
||||
"discord.js": "^14.16.3",
|
||||
|
@ -16,6 +17,7 @@
|
|||
"prismarine-auth": "^2.2.0",
|
||||
"prismarine-chat": "^1.10.1",
|
||||
"prismarine-registry": "^1.7.0",
|
||||
"proxy-agent": "^6.4.0",
|
||||
"wikipedia": "^2.1.2",
|
||||
"xml2js": "^0.6.2"
|
||||
}
|
||||
|
|
40
src/bot.js
40
src/bot.js
|
@ -1,8 +1,9 @@
|
|||
const mc = require('minecraft-protocol')
|
||||
const { EventEmitter } = require('events')
|
||||
//require("events").EventEmitter.defaultMaxListeners = Infinity;
|
||||
EventEmitter.defaultMaxListeners = Infinity
|
||||
const mc = require('minecraft-protocol');
|
||||
const { EventEmitter } = require('events');
|
||||
EventEmitter.defaultMaxListeners = Infinity;
|
||||
const util = require('util');
|
||||
const createRegistry = require('prismarine-registry');
|
||||
const ChatMessage = require('prismarine-chat');
|
||||
function createBot(options = {}, config) {
|
||||
const bot = new EventEmitter();
|
||||
bot.options = {
|
||||
|
@ -12,7 +13,6 @@ function createBot(options = {}, config) {
|
|||
hideErrors: options.hideErrors ??= true, // HACK: Hide errors by default as a lazy fix to console being spammed with them
|
||||
};
|
||||
bot.options = options;
|
||||
const ChatMessage = require('prismarine-chat')(bot.options.version);
|
||||
// Create our client object, put it on the bot, and register some events
|
||||
bot.on('init_client', client => {
|
||||
client.on('packet', (data, meta) => {
|
||||
|
@ -23,25 +23,24 @@ function createBot(options = {}, config) {
|
|||
client.on('login', () => {
|
||||
bot.uuid = client.uuid
|
||||
bot.username = client.username
|
||||
bot.registry = createRegistry(client.version)
|
||||
bot.registry.language = require('./data/language.json');
|
||||
bot.emit('registry_ready', bot.registry)
|
||||
})
|
||||
client.on('disconnect', (data) => {
|
||||
bot.emit("disconnect", data)
|
||||
// bot.console.info(JSON.stringify(data))
|
||||
// bot?.discord?.channel?.send(util.inspect(data.reason))
|
||||
if (config.console.filelogger) {
|
||||
// bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(data.reason))
|
||||
}
|
||||
client.on('disconnect', data => {
|
||||
bot.emit("disconnect", data);
|
||||
console.log(ChatMessage(bot._client.version).fromNotch(data.reason)?.toAnsi())
|
||||
bot.console.warn(`${ChatMessage(bot._client.version).fromNotch("§8[§bClient Reconnect§8]§r")?.toAnsi()} ${ChatMessage(bot._client.version).fromNotch(data.reason)?.toAnsi()}`)
|
||||
})
|
||||
client.on('end', reason => {
|
||||
bot.emit('end', reason);
|
||||
if (reason === "socketClosed") return;
|
||||
bot.console.warn(ChatMessage(bot._client.version).fromNotch(`§8[§bClient Reconnect§8]§r ${reason}`)?.toAnsi())
|
||||
})
|
||||
|
||||
client.on('error', error => {
|
||||
bot.console.warn(ChatMessage.fromNotch('§8[§bClient Reconnect§8]§r ')?.toAnsi() + util.inspect(error.toString()))
|
||||
// bot?.discord?.channel?.send(error.toString())
|
||||
if (config.console.filelogger) {
|
||||
// bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(error.toString()))
|
||||
}
|
||||
bot.console.warn(ChatMessage(bot._client.version).fromNotch('§8[§bClient Reconnect§8]§r ')?.toAnsi() + util.inspect(error.toString()))
|
||||
bot?.discord?.channel?.send(error.toString())
|
||||
})
|
||||
|
||||
client.on("keep_alive", ({ keepAliveId }) => {
|
||||
|
@ -50,11 +49,8 @@ function createBot(options = {}, config) {
|
|||
|
||||
client.on('kick_disconnect', (data) => {
|
||||
bot.emit("kick_disconnect", data.reason)
|
||||
bot.console?.warn(ChatMessage.fromNotch(`§8[§bClient Reconnect§8]§r `)?.toAnsi() + util.inspect(data.reason))
|
||||
bot.console?.warn(`${ChatMessage(bot._client.version).fromNotch("§8[§bClient Reconnect§8]§r")?.toAnsi()} ${ChatMessage(bot._client.version).fromNotch(data.reason)?.toAnsi()}`)
|
||||
bot?.discord?.channel?.send(util.inspect(data.reason))
|
||||
if (config.console.filelogger) {
|
||||
// bot?.console?.filelogging(`[${new Date().toLocaleTimeString("en-US", { timeZone: "America/CHICAGO", })} ${new Date().toLocaleDateString("en-US", { timeZone: "America/CHICAGO", })} logs] [${options.serverName}] ` + '[Client Reconnect] ' + util.inspect(data.reason))
|
||||
}
|
||||
})
|
||||
|
||||
process.on("uncaughtException", (e) => {
|
||||
|
@ -62,7 +58,7 @@ function createBot(options = {}, config) {
|
|||
});
|
||||
})
|
||||
|
||||
const client = options.client ?? new mc.createClient(options)
|
||||
const client = options.client ?? new mc.createClient(bot.options)
|
||||
bot._client = client
|
||||
bot.emit('init_client', client)
|
||||
bot.bots = options.bots ?? [bot]
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
const CommandError = require('../util/command_error');
|
||||
module.exports = {
|
||||
name: 'filter',
|
||||
trustLevel: 1,
|
||||
trustLevel: 2,
|
||||
aliases: [
|
||||
"blacklist"
|
||||
],
|
||||
|
|
|
@ -54,6 +54,15 @@ module.exports = {
|
|||
}
|
||||
break
|
||||
case 'config':
|
||||
if (bot.options.isKaboom) {
|
||||
mode = 'Kaboom'
|
||||
} else if (bot.options.isCreayun) {
|
||||
mode = 'Creayun'
|
||||
} else if (bot.options.useChat) {
|
||||
mode = 'useChat / Kaboom'
|
||||
} else if (bot.options.isSavage) {
|
||||
mode = 'Savage'
|
||||
}
|
||||
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, [
|
||||
{
|
||||
text: `Minecraft username \u203a ${bot.options.username}\n`,
|
||||
|
@ -104,6 +113,14 @@ module.exports = {
|
|||
color: 'gold'
|
||||
},
|
||||
{
|
||||
text: 'Mode \u203a ',
|
||||
color: 'gray'
|
||||
},
|
||||
{
|
||||
text: `${mode}`,
|
||||
color: 'gray',
|
||||
}
|
||||
/* {
|
||||
text: `isKaboom \u203a ${bot.options.isKaboom}\n`,
|
||||
color: "gray",
|
||||
},
|
||||
|
@ -114,7 +131,7 @@ module.exports = {
|
|||
{
|
||||
text: `isSavage \u203a ${bot.options.isSavage}`,
|
||||
color: "gray",
|
||||
},
|
||||
},*/
|
||||
]);
|
||||
break;
|
||||
case 'discord':
|
||||
|
|
|
@ -83,7 +83,7 @@ module.exports = {
|
|||
}
|
||||
component.pop()
|
||||
const ansi = bot.getMessageAsPrismarine([{ text: `Players: `, color:'gray' }, { text: '(' , color: 'gray' }, { text: `${JSON.stringify(bot.players.length)}`, color: 'gold' }, { text: ')\n', color: 'gray' }, component])?.toAnsi()
|
||||
const fix = fixansi(ansi.replaceAll('`', '`\u200b'))
|
||||
const fix = fixansi(ansi.replaceAll('`', '`\u200b').substring(0, 3080))
|
||||
const Embed = new EmbedBuilder()
|
||||
.setColor(`${config.colors.discord.embed}`)
|
||||
.setTitle(`${this.name} Command`)
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
module.exports = {
|
||||
name: 'reload',
|
||||
trustLevel: 3,
|
||||
aliases: [
|
||||
],
|
||||
description: 'reloads commands',
|
||||
usages: [
|
||||
""
|
||||
],
|
||||
execute (context) {
|
||||
const bot = context.bot
|
||||
bot.tellraw("@a", [
|
||||
{ text: "Reloading ", color: "gray" },
|
||||
{ text: '(', color: "gray" },
|
||||
{ text: `${bot.commandManager.commandlist.length}`, color: "gold" },
|
||||
{ text: ') ', color: "gray" },
|
||||
{ text: 'commands', color: "gray" },
|
||||
])
|
||||
for (const eachBot of bot.bots) {
|
||||
eachBot.commandManager.reload();
|
||||
}
|
||||
},
|
||||
discordExecute (context) {
|
||||
const bot = context.bot;
|
||||
bot.discord.message.reply("Reloading Commands,.........");
|
||||
for (const eachBot of bot.bots) {
|
||||
eachBot.commandManager.reload();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
const { parseString } = require('xml2js');
|
||||
const CommandError = require('../util/command_error')
|
||||
const util = require('util');
|
||||
module.exports = {
|
||||
name: 'xml',
|
||||
trustLevel: 3,
|
||||
aliases: [
|
||||
],
|
||||
description: 'eval xml shit',
|
||||
usages: [
|
||||
"<xml code>"
|
||||
],
|
||||
execute (context) {
|
||||
const bot = context.bot;
|
||||
const args = context.arguments;
|
||||
parseString(args.slice(1).join(' '), function (err, result) {
|
||||
if (err) throw new CommandError(err.toString())
|
||||
bot.tellraw("@a", [
|
||||
{
|
||||
text: "Result \u203a \n",
|
||||
color: "gray"
|
||||
},
|
||||
{
|
||||
text: `${util.inspect(result)}`
|
||||
}
|
||||
])
|
||||
});
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
prefixes:
|
||||
- "!"
|
||||
- "fnfbfbot!"
|
||||
|
||||
discord:
|
||||
token: "discord token here"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
{
|
||||
"bot": {
|
||||
"buildstring": {
|
||||
"version": "v6.0.6",
|
||||
"build":"1060",
|
||||
"version": "v6.0.7",
|
||||
"build":"1080",
|
||||
"codename":""
|
||||
},
|
||||
"source": "https://code.chipmunk.land/Parker2991/FridayNightFunkinBoyfriendBot/"
|
||||
|
|
1
src/data/trustedPlayers.json
Normal file
1
src/data/trustedPlayers.json
Normal file
|
@ -0,0 +1 @@
|
|||
[{"player":"aaa"},{"player":"Parker2991"},{"player":"FNFBoyfriendBot"}]
|
|
@ -4,10 +4,13 @@ const loadModules = require('./util/loadModules');
|
|||
const js_yaml = require('js-yaml');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const checks = require('./util/checks');
|
||||
const { Client, GatewayIntentBits } = require('discord.js');
|
||||
const { MessageContent, GuildMessages, Guilds } = GatewayIntentBits;
|
||||
const discordClient = new Client({ intents: [Guilds, GuildMessages, MessageContent] });
|
||||
console.log('Starting FNFBoyfriendBot');
|
||||
checks();
|
||||
/*
|
||||
if (!fs.existsSync(path.join(__dirname, "../config.yml"))) {
|
||||
console.log("Config not found creating config from the default config");
|
||||
fs.copyFileSync(
|
||||
|
@ -15,6 +18,7 @@ if (!fs.existsSync(path.join(__dirname, "../config.yml"))) {
|
|||
path.join(__dirname, "../config.yml")
|
||||
)
|
||||
}
|
||||
*/
|
||||
try {
|
||||
config = js_yaml.load(fs.readFileSync(path.join(__dirname, '../', 'config.yml')))
|
||||
} catch (e) {
|
||||
|
|
24
src/modules/chat_command_handler.js
Normal file
24
src/modules/chat_command_handler.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
const CommandSource = require('../util/command_source');
|
||||
module.exports = (bot, options, config) => {
|
||||
let ratelimit = 0;
|
||||
bot.on("parsed_message", (data) => {
|
||||
if (data.type !== "minecraft:chat") return;
|
||||
const prefixes = config.prefixes;
|
||||
prefixes.map((prefix) => {
|
||||
const plainMessage = bot.getMessageAsPrismarine(data.contents)?.toString();
|
||||
if (!plainMessage.startsWith(prefix)) return
|
||||
const command = plainMessage.substring(prefix.length)
|
||||
const source = new CommandSource(data.sender, { discord: false, console: false }, true)
|
||||
ratelimit++
|
||||
setTimeout(() => {
|
||||
ratelimit--
|
||||
}, 1000)
|
||||
if (ratelimit > 2) {
|
||||
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, { text: 'You are using commands too fast!', color: 'dark_red'})
|
||||
} else if (command.split(" ")[0].length === 0) {
|
||||
} else {
|
||||
bot.commandManager.executeString(source, command)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
|
@ -3,7 +3,7 @@ const path = require('path');
|
|||
const CommandError = require('../util/command_error.js');
|
||||
const CommandSource = require('../util/command_source');
|
||||
const { EmbedBuilder } = require('discord.js');
|
||||
function command_manager (bot, options, config, discordClient) {
|
||||
async function command_manager (bot, options, config, discordClient) {
|
||||
bot.commandManager = {
|
||||
commands: {},
|
||||
commandlist: [],
|
||||
|
@ -20,20 +20,16 @@ function command_manager (bot, options, config, discordClient) {
|
|||
}
|
||||
} else if (!source?.sources?.discord && !source?.sources?.console) {
|
||||
if (!command || !command.execute)
|
||||
throw new CommandError([
|
||||
{
|
||||
translate: `command.unknown.command`
|
||||
},
|
||||
{
|
||||
text: '\n'
|
||||
},
|
||||
{
|
||||
text: `${commandName} `
|
||||
},
|
||||
{
|
||||
translate: "command.context.here"
|
||||
}
|
||||
])
|
||||
throw new CommandError({
|
||||
translate: "%s%s%s %s",
|
||||
color: "dark_gray",
|
||||
with: [
|
||||
{ translate: "command.unknown.command", color: "red" },
|
||||
{ text: "\n" },
|
||||
{ text: `${commandName}` },
|
||||
{ translate: "command.context.here", color: "red" }
|
||||
]
|
||||
})
|
||||
} else if (source?.sources?.console && !source?.sources?.discord) {
|
||||
if (!command || !command.execute)
|
||||
bot.console.warn([
|
||||
|
@ -58,27 +54,24 @@ function command_manager (bot, options, config, discordClient) {
|
|||
const event = bot.discord.message;
|
||||
const roles = event?.member?.roles?.cache;
|
||||
if (command?.trustLevel === 1 && !source?.sources?.discord) {
|
||||
if (args.length === 0 && bot.validation.trusted && bot.validation.admin && bot.validation.owner && !source?.sources?.console) throw new CommandError({ text: "Please provide an trusted or an admin or an owner hash" })
|
||||
if (args.length === 0 && bot.validation.trusted && bot.validation.admin && bot.validation.owner && !source?.sources?.console) throw new CommandError({ text: "Please provide an trusted or an admin or an owner hash", color: "dark_red" })
|
||||
if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.admin && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or admin or owner hash', color: 'dark_red' });
|
||||
// if (args[0] === bot.validation.trusted || args[0] === bot.validation.admin || args[0] === bot.validation.owner) bot.validation.update();
|
||||
} else if (command?.trustLevel === 1 && source?.sources.discord) {
|
||||
const hasRole = roles?.some(role => role.name === `${config.discord.roles.trusted}` || role.name === `${config.discord.roles.owner}`)
|
||||
if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!' })
|
||||
if (!hasRole) throw new CommandError({ translate: 'You are not trusted or the owner!', color: "dark_red" })
|
||||
}
|
||||
if (command?.trustLevel === 2 && !source.sources.console) {
|
||||
if (args.length === 0 && bot.validation.admin && bot.validation.owner && !source.sources.console) throw new CommandError({ text: "Please provide an trusted or owner hash" })
|
||||
if (args.length === 0 && bot.validation.admin && bot.validation.owner && !source.sources.console) throw new CommandError({ text: "Please provide an trusted or owner hash", color: 'dark_red' })
|
||||
if (args[0] !== bot.validation.trusted && args[0] !== bot.validation.owner && !source.sources.console) throw new CommandError({ translate: 'Invalid trusted or owner hash', color: 'dark_red' });
|
||||
// if (args[0] === bot.validation.admin || args[0] === bot.validation.owner) bot.validation.update();
|
||||
}
|
||||
if (command?.trustLevel === 3 && !source.sources.discord && !source.sources.console) {
|
||||
if (args.length === 0 && bot.validation.owner) throw new CommandError({ text: "Please provide an owner hash" })
|
||||
if (args.length === 0 && bot.validation.owner) throw new CommandError({ text: "Please provide an owner hash", color: "dark_red" })
|
||||
if (args[0] !== bot.validation.owner) throw new CommandError({ translate: 'Invalid owner hash', color: 'dark_red' })
|
||||
// if (args[0] === bot.validation.owner) bot.validation.update();
|
||||
} else if (command?.trustLevel === 3 && source.sources.discord && !source.sources.console) {
|
||||
const hasRole = roles?.some(role => role.name === `${config.discord.roles.owner}`)
|
||||
if (!hasRole) throw new CommandError({ translate: 'You are not the owner!' })
|
||||
if (!hasRole) throw new CommandError({ translate: 'You are not the owner!', color: "dark_red" })
|
||||
} else if (command?.trustLevel === 4 && !source.sources.console) {
|
||||
throw new CommandError('This command can only be ran via console');
|
||||
throw new CommandError({ text: 'This command can only be ran via console', color: "dark_red" });
|
||||
}
|
||||
}
|
||||
if (!command?.discordExecute && command && source?.sources?.discord) {
|
||||
|
@ -107,7 +100,7 @@ function command_manager (bot, options, config, discordClient) {
|
|||
if (bot.options.isSavage || bot.options.isCreayun) {
|
||||
bot.chat.message(`&4${error.message}`)
|
||||
} else {
|
||||
bot.tellraw("@a", { text: error.message, color: "dark_red" })
|
||||
bot.tellraw("@a", error._message)
|
||||
}
|
||||
} else {
|
||||
if (bot.options.isSavage || bot.options.isCreayun) {
|
||||
|
@ -116,11 +109,10 @@ function command_manager (bot, options, config, discordClient) {
|
|||
bot.tellraw("@a", [{ translate: 'command.failed', color: "dark_red", hoverEvent: { action: 'show_text', contents: `${error.stack}` } }])
|
||||
}
|
||||
}
|
||||
// else bot.tellraw("@a", [{ translate: 'command.failed', color: "dark_red", hoverEvent: { action: 'show_text', contents: `${error.stack}` } }])
|
||||
//}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
executeString (source, command) {
|
||||
const [commandName, ...args] = command.split(' ')
|
||||
return this.execute(source, commandName, args)
|
||||
|
@ -139,9 +131,11 @@ function command_manager (bot, options, config, discordClient) {
|
|||
command.aliases.map((a) => (this.commands[a] = command));
|
||||
}
|
||||
},
|
||||
|
||||
unregister (command) {
|
||||
this.commands = {};
|
||||
},
|
||||
|
||||
getCommand (name) {
|
||||
return this.commands[name]
|
||||
},
|
||||
|
@ -149,54 +143,23 @@ function command_manager (bot, options, config, discordClient) {
|
|||
getCommands () {
|
||||
return Object.values(this.commands)
|
||||
},
|
||||
|
||||
reload() {
|
||||
for (const filename of fs.readdirSync(path.join(__dirname, "../commands"))) {
|
||||
try {
|
||||
delete require.cache[require.resolve(path.join(__dirname, "../commands/", filename))]
|
||||
const command = require(path.join(__dirname, "../commands/", filename));
|
||||
bot.commandManager.register(command);
|
||||
bot.commandManager.commandlist.pop(command)
|
||||
bot.commandManager.commandlist.push(command)
|
||||
} catch (error) {
|
||||
bot.tellraw("@a", { text: `Failed to reload file ${filename}\n${error.stack}`, color: "red" })
|
||||
bot?.console?.fileLogger(error.stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
commandlist = [];
|
||||
for (const filename of fs.readdirSync(path.join(__dirname, '../commands'))) {
|
||||
try {
|
||||
const command = require(path.join(__dirname, '../commands', filename))
|
||||
bot.commandManager.register(command)
|
||||
bot.commandManager.commandlist.push(command)
|
||||
if (filename.endsWith('.mjs')) {
|
||||
let commands = await import(path.join(__dirname, '../commands', filename))
|
||||
bot.commandManager.register(commands.command);
|
||||
bot.commandManager.commandlist.push(commands.command);
|
||||
} if (filename.endsWith('.js')) {
|
||||
let commands = require(path.join(__dirname, '../commands', filename));
|
||||
bot.commandManager.register(commands);
|
||||
bot.commandManager.commandlist.push(commands);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load command', filename, ':', error)
|
||||
bot?.console.filelogging(error.stack)
|
||||
console.error('Failed to load command ', filename, ':', error)
|
||||
}
|
||||
}
|
||||
let ratelimit = 0;
|
||||
bot.on("parsed_message", (data) => {
|
||||
if (data.type !== "minecraft:chat") return;
|
||||
const prefixes = config.prefixes;
|
||||
prefixes.map((prefix) => {
|
||||
const plainMessage = bot.getMessageAsPrismarine(data.contents)?.toString();
|
||||
if (!plainMessage.startsWith(prefix)) return
|
||||
const command = plainMessage.substring(prefix.length)
|
||||
const source = new CommandSource(data.sender, { discord: false, console: false }, true)
|
||||
ratelimit++
|
||||
setTimeout(() => {
|
||||
ratelimit--
|
||||
}, 1000)
|
||||
if (ratelimit > 2) {
|
||||
bot.tellraw(`@a[name="${source?.player?.profile?.name}"]`, { text: 'You are using commands too fast!', color: 'dark_red'})
|
||||
} else if (command.split(" ")[0].length === 0) {
|
||||
} else {
|
||||
bot.commandManager.executeString(source, command)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
module.exports = command_manager;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
const CommandSource = require('../util/command_source');
|
||||
const prismarineChat = require('prismarine-chat')('1.20.2');
|
||||
const convert = require('color-convert')
|
||||
function Console (bot, options, config) {
|
||||
let rateLimit = 0;
|
||||
bot.console = {
|
||||
|
@ -40,34 +39,28 @@ function Console (bot, options, config) {
|
|||
},
|
||||
customChat: {
|
||||
enabled: false,
|
||||
rainbow: false,
|
||||
chat (message) {
|
||||
if (this.rainbow) {
|
||||
|
||||
|
||||
} else {
|
||||
prefix = {
|
||||
translate: '[%s] %s \u203a %s',
|
||||
color:'dark_gray',
|
||||
with: [
|
||||
{
|
||||
text: 'FNFBoyfriendBot Console',
|
||||
color:'#00FFFF'
|
||||
},
|
||||
{
|
||||
selector: `${bot.username}`, color:'#00FFFF',
|
||||
clickEvent: { action: 'suggest_command', value: `${config.prefixes[0]}help` }
|
||||
},
|
||||
{
|
||||
text: '',
|
||||
extra: [`${message}`],
|
||||
color:'white'
|
||||
},
|
||||
],
|
||||
hoverEvent: { action:"show_text", value: 'FNF Sky is a fangirl but a simp for boyfriend confirmed??'},
|
||||
clickEvent: 'https://doin-your.mom' ?
|
||||
{ action: 'open_url', value: 'https://doin-your.mom' } : undefined,
|
||||
}
|
||||
const prefix = {
|
||||
translate: '[%s] %s \u203a %s',
|
||||
color:'dark_gray',
|
||||
with: [
|
||||
{
|
||||
text: 'FNFBoyfriendBot Console',
|
||||
color:'#00FFFF'
|
||||
},
|
||||
{
|
||||
selector: `${bot.username}`, color:'#00FFFF',
|
||||
clickEvent: { action: 'suggest_command', value: `${config.prefixes[0]}help` }
|
||||
},
|
||||
{
|
||||
text: '',
|
||||
extra: [`${message}`],
|
||||
color:'white'
|
||||
},
|
||||
],
|
||||
hoverEvent: { action:"show_text", value: 'FNF Sky is a fangirl but a simp for boyfriend confirmed??'},
|
||||
clickEvent: 'https://doin-your.mom' ?
|
||||
{ action: 'open_url', value: 'https://doin-your.mom' } : undefined,
|
||||
}
|
||||
bot.tellraw('@a', prefix)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@ const fs = require('fs');
|
|||
const path = require('path');
|
||||
function filter (bot, options, config, discordClient) {
|
||||
if (options.isSavage || options.isCreayun) return;
|
||||
// filter v5 (not to be confused with the bot version)
|
||||
// filter v6 (not to be confused with the bot version)
|
||||
bot.filter = {
|
||||
list () {
|
||||
try {
|
||||
|
@ -38,72 +38,46 @@ function filter (bot, options, config, discordClient) {
|
|||
}
|
||||
bot.on('message', async (data) => {
|
||||
for (const filteredPlayer of JSON.parse(fs.readFileSync(path.join(__dirname, '../data/filter.json')))) {
|
||||
let player_completion = (await bot.tab_complete('deop ')).filter(_ => _.tooltip == undefined);
|
||||
// for (const eachBot of bot.bots) {
|
||||
let player_completion = (await bot.tab_complete('deop ')).filter(_ => _.tooltip == undefined);
|
||||
player_completion.forEach(async (player) => {
|
||||
if (filteredPlayer.ignoreCase) {
|
||||
|
||||
// console.log(muted);
|
||||
// console.log(player_completion[0].match.toLowerCase());
|
||||
// console.log(bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayers.name.toLowerCase()).gamemode)
|
||||
player_completion.forEach(async (player) => {
|
||||
if (filteredPlayer.ignoreCase) {
|
||||
if (player.match !== bot.players.find((players) => players.profile.name === filteredPlayer.name.toLowerCase()).profile.name) return;
|
||||
if (player.match === bot.players.find((players) => players.profile.name === filteredPlayer.name.toLowerCase()).profile.name) {
|
||||
if (!bot.players.find((players) => players.profile.name === filteredPlayer.name.toLowerCase()).profile.name) return;
|
||||
bot.core.run(`execute run deop @a[name="${bot.players.find((players) => players.profile.name === filteredPlayer.name.toLowerCase()).profile.name}"]`);
|
||||
} else {
|
||||
// if (player.match !== eachBot.players.find((players) => players.profile.name === filteredPlayer.name).profile.name) return;
|
||||
if (bot.players.find((players) => players.profile.name === player.match).profile.name === filteredPlayer.name === true) {
|
||||
|
||||
bot.core.run(`execute run deop @a[name="${bot.players.find((players) => players.profile.name === filteredPlayer.name).profile.name}"]`);
|
||||
}
|
||||
}
|
||||
})
|
||||
if (filteredPlayer.ignoreCase) {
|
||||
|
||||
} else {
|
||||
if (player.match !== bot.players.find((players) => players.profile.name === filteredPlayer.name).profile.name) return;
|
||||
if (player.match === bot.players.find((players) => players.profile.name === filteredPlayer.name).profile.name) {
|
||||
if (!bot.players.find((players) => players.profile.name === filteredPlayer.name).profile.name) return;
|
||||
bot.core.run(`execute run deop @a[name="${bot.players.find((players) => players.profile.name === filteredPlayer.name).profile.name}"]`);
|
||||
// if (!eachBot.players.find((player) => players.profile.name === filteredPlayer.name)) return
|
||||
if (bot.players.find((players) => players.profile.name === JSON.parse(filteredPlayer.name)).gamemode !== 2) {
|
||||
// if (eachBot.players.find((player) => players.profile.name !== filteredPlayer.name)) return
|
||||
bot.core.run(`execute run gamemode adventure @a[name="${bot.players.find((player) => player.profile.name === filteredPlayer.name).profile.name}"]`);
|
||||
}
|
||||
}
|
||||
// if (filteredPlayer.ignoreCase) {
|
||||
/// console.log('e');
|
||||
// }
|
||||
//if (filteredPlayer.ignoreCase) {
|
||||
// if (player.match !== bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayer.name.toLowerCase())) return;
|
||||
// if (player.match === bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayer.name.toLowerCase())) {
|
||||
// bot.core.run(`execute run deop @a[name="${bot.players.find((players) => players.profile.name === filteredPlayer.name).profile.name}"]`);
|
||||
//}
|
||||
//if (bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayer.name.toLowerCase()).gamemode !== 2) {
|
||||
//console.log('e');
|
||||
// bot.core.run(`execute run gamemode adventure @a[name="${bot.players.find((players) => players.profile.name.toLowerCase() === filteredPlayer.name.toLowerCase()).profile.name}"]`);
|
||||
//}
|
||||
// }
|
||||
})
|
||||
/* if (player.match !== bot.players.find((players) => players.profile.name === filteredPlayer.name).profile.name) return;
|
||||
if (player.match === bot.players.find((players) => players.profile.name === filteredPlayer.name).profile.name) {
|
||||
bot.core.run(`execute run deop @a[name="${bot.players.find((players) => players.profile.name === filteredPlayer.name).profile.name}"]`);
|
||||
}*/
|
||||
/* if (!player) return;
|
||||
if (player) {
|
||||
if (!bot.players.find((players) => players.profile.name === filteredPlayer.name).profile.name) return;
|
||||
bot.core.run(`execute run deop @a[name="${bot.players.find((players) => players.profile.name === filteredPlayer.name).profile.name}"]`);
|
||||
}*/
|
||||
// console.log(player);
|
||||
// })
|
||||
}
|
||||
/* bot.players.forEach(async (player) => {
|
||||
if (player) {
|
||||
console.log(player_complete);
|
||||
}
|
||||
})*/
|
||||
// }
|
||||
})
|
||||
bot.on('parsed_message', (data) => {
|
||||
try {
|
||||
for (const filteredPlayer of JSON.parse(fs.readFileSync(path.join(__dirname, '../data/filter.json')))) {
|
||||
if (filteredPlayer.ignoreCase) {
|
||||
|
||||
|
||||
} else {
|
||||
if (bot?.players?.find((player) => player?.profile?.name === filteredPlayer.name)?.profile?.name === data?.sender?.profile?.name) {
|
||||
bot.core.run(`essentials:mute ${bot?.players?.find((player) => player?.profile?.name === filteredPlayer.name)?.uuid} 10y`);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.log(e.stack);
|
||||
}
|
||||
})
|
||||
}
|
||||
module.exports = filter;
|
||||
/*
|
||||
let player_completion = (await bot.tab_complete('scoreboard players add ')).filter(_ => _.tooltip == undefined) // exclude>
|
||||
let op = (await bot.tab_complete('minecraft:op ')).filter(_ => _.tooltip == undefined);
|
||||
bot.players.forEach(async player => {
|
||||
if(!players.includes(player.uuid)) return
|
||||
|
||||
const a = player_completion.filter(_ => _.match == player.profile.name)
|
||||
const b = op.filter(_ => _.match == player.profile.name);
|
||||
//console.log(b)
|
||||
if(a.length >= 1) {
|
||||
player.vanished = true
|
||||
} else {
|
||||
bot.players = bot.players.filter(_ => _.uuid != player.uuid)
|
||||
}
|
||||
})
|
||||
*/
|
||||
|
|
|
@ -24,8 +24,6 @@ function player_list (bot, options, config) {
|
|||
if(!players.includes(player.uuid)) return
|
||||
|
||||
const a = player_completion.filter(_ => _.match == player.profile.name)
|
||||
const b = op.filter(_ => _.match == player.profile.name);
|
||||
//console.log(b)
|
||||
if(a.length >= 1) {
|
||||
player.vanished = true
|
||||
} else {
|
||||
|
@ -39,7 +37,6 @@ function player_list (bot, options, config) {
|
|||
bot.players.push({
|
||||
uuid: entry.uuid,
|
||||
profile: { name: entry.player.name, properties: entry.player.properties },
|
||||
// opped: false,
|
||||
chatSession: undefined,
|
||||
gamemode: undefined,
|
||||
listed: undefined,
|
||||
|
@ -67,21 +64,6 @@ function player_list (bot, options, config) {
|
|||
target.listed = entry.listed
|
||||
}
|
||||
|
||||
/* async function op (target) {
|
||||
// let player_completion = (await bot.tab_complete('minecraft:op ')).filter(_ => _.tooltip === undefined);
|
||||
// console.log(player_completion);
|
||||
bot.players.forEach(async player => {
|
||||
if (!players.includes(player.uuid)) return;
|
||||
let player_completion = (await bot.tab_complete('minecraft:op ')).filter(_ => _.tooltip === undefined);
|
||||
const op = player_completion.filter(_ => _.match === players.profile.name);
|
||||
console.log(op);
|
||||
if (op.length >= 1) {
|
||||
player.opped = true
|
||||
}
|
||||
})
|
||||
target.opped = true
|
||||
}*/
|
||||
|
||||
function updateLatency (entry) {
|
||||
const target = bot.players.find(_entry => _entry.uuid === entry.uuid)
|
||||
if (!target) return
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
const createRegistry = require('prismarine-registry')
|
||||
|
||||
function registry (bot) {
|
||||
bot.on('packet.login', packet => {
|
||||
bot.registry = createRegistry(bot._client.version)
|
||||
bot.registry.language = require('../data/language.json');
|
||||
bot.emit('registry_ready', bot.registry)
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = registry;
|
23
src/util/checks.js
Normal file
23
src/util/checks.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
module.exports = () => {
|
||||
if (!fs.existsSync(path.join(__dirname, "../../config.yml"))) {
|
||||
console.warn("Config not found creating config from the default config");
|
||||
fs.copyFileSync(
|
||||
path.join(__dirname, "../data/default_config.yml"),
|
||||
path.join(__dirname, "../../config.yml")
|
||||
)
|
||||
}
|
||||
|
||||
if (!fs.existsSync(path.join(__dirname, "../data/filter.json"))) {
|
||||
console.warn("filter json not found creating the file,......");
|
||||
let data = [{ ignoreCase: false, regexed: false, name: 'whatever player username idfk' }]
|
||||
fs.writeFileSync(path.join(__dirname, "../data/filter.json"), JSON.stringify(data))
|
||||
}
|
||||
|
||||
if (!fs.existsSync(path.join(__dirname, "../data/trustedPlayers.json"))) {
|
||||
console.warn("Trusted Players json not found creating the file,......");
|
||||
let data = [{player: ""}]
|
||||
fs.writeFileSync(path.join(__dirname, "../data/trustedPlayers.json"), JSON.stringify(data))
|
||||
}
|
||||
}
|
|
@ -1,15 +1,38 @@
|
|||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
function loadModules (bot, options, config, discordClient) {
|
||||
async function loadModules (bot, options, config, discordClient) {
|
||||
// let module
|
||||
bot.loadModule = module => module(bot, options, config, discordClient)
|
||||
|
||||
for (const filename of fs.readdirSync(path.join(__dirname, '../', 'modules'))) {
|
||||
try {
|
||||
const module = require(path.join(__dirname, '../', 'modules', filename))
|
||||
bot.loadModule(module)
|
||||
if (filename.endsWith(".mjs")) {
|
||||
// const module = await import(path.join(__dirname, '../', 'modules', filename));
|
||||
// bot.loadModule(module);
|
||||
} else if (filename.endsWith(".js")) {
|
||||
const module = require(path.join(__dirname, '../', 'modules', filename));
|
||||
bot.loadModule(module);
|
||||
}
|
||||
//bot.loadModule(module)
|
||||
} catch (error) {
|
||||
console.error('Failed to load module', filename, ':', error)
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = loadModules;
|
||||
/*
|
||||
for (const filename of fs.readdirSync(path.join(__dirname, '../commands'))) {
|
||||
try {
|
||||
if (filename.endsWith('.mjs')) {
|
||||
let commands = await import(path.join(__dirname, '../commands', filename))
|
||||
bot.commandManager.register(commands.command);
|
||||
bot.commandManager.commandlist.push(commands.command);
|
||||
} if (filename.endsWith('.js')) {
|
||||
let commands = require(path.join(__dirname, '../commands', filename));
|
||||
bot.commandManager.register(commands);
|
||||
bot.commandManager.commandlist.push(commands);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Failed to load command', filename, ':', error)
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
|
Loading…
Reference in a new issue