From 85821f5fa31e27aed082da7a0f35cbee9de6af7e Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Sat, 2 Nov 2024 22:48:21 +0100 Subject: [PATCH 01/15] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b33dd4..71b3e53 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ You can also change the global prefix. You should enter you discord user id, so you can use the admin commands. Every time you want to change something in this file, you have to restart the bot. -If the config is ever changed, you need to either delete it and repeat the steps above or take a look at the util/createInitialConfig.js file. +If the config is ever changed, you need to either delete it and repeat the steps above or take a look at the [util/createInitialConfig.js](./util/createInitialConfig.js) file. ## Known issues From bab508e4b919ee9933aa62d477e93a496c103296 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 5 Nov 2024 05:26:48 +0100 Subject: [PATCH 02/15] Add eslint as linter and add linter workflow --- .github/workflows/lint.yml | 22 + eslint.config.mjs | 32 + package-lock.json | 1135 +++++++++++++++++++++++++++++++++++- package.json | 7 +- 4 files changed, 1191 insertions(+), 5 deletions(-) create mode 100644 .github/workflows/lint.yml create mode 100644 eslint.config.mjs diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..5f16ea2 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,22 @@ +name: Lint Codebase + +on: [push] + +jobs: + eslint: + runs-on: node + + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 'latest' + + - name: Install dependencies + run: npm install + + - name: Run ESLint + run: npm run lint \ No newline at end of file diff --git a/eslint.config.mjs b/eslint.config.mjs new file mode 100644 index 0000000..0e1fd77 --- /dev/null +++ b/eslint.config.mjs @@ -0,0 +1,32 @@ +import jest from "eslint-plugin-jest"; +import globals from "globals"; +export default [{ + plugins: { + jest, + }, + + languageOptions: { + globals: { + ...globals.jest, + ...jest.environments.globals.globals, + }, + }, + + rules: { + "no-fallthrough": "error", + "no-case-declarations": "error", + "no-unused-vars": "warn" + }, + +}, +]; + + + + +// /** @type {import('eslint').Linter.Config[]} */ +// export default [ +// {files: ["**/*.js"], languageOptions: {sourceType: "commonjs"}}, +// {languageOptions: { globals: globals.node }}, +// pluginJs.configs.recommended, +// ]; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index a992a45..b709ab6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,11 @@ "sqlite3": "^5.1.6" }, "devDependencies": { + "@eslint/js": "^9.14.0", "@types/jest": "^29.5.14", + "eslint": "^9.14.0", + "eslint-plugin-jest": "^28.8.3", + "globals": "^15.12.0", "jest": "^29.7.0" } }, @@ -643,6 +647,16 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/traverse/node_modules/globals": { + "version": "11.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", + "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/@babel/types": { "version": "7.25.8", "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.25.8.tgz", @@ -816,6 +830,176 @@ "integrity": "sha512-urGGYeWtWNYMKnYlZnOnDHm8fVRffQs3U0SpE8RHeiuLKb/u92APS8HoQnPTFbnXmY1vVnXjXO4dOxcAn3J+DA==", "license": "MIT" }, + "node_modules/@eslint-community/eslint-utils": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/@eslint-community/eslint-utils/-/eslint-utils-4.4.1.tgz", + "integrity": "sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + }, + "peerDependencies": { + "eslint": "^6.0.0 || ^7.0.0 || >=8.0.0" + } + }, + "node_modules/@eslint-community/eslint-utils/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint-community/regexpp": { + "version": "4.12.1", + "resolved": "https://registry.npmjs.org/@eslint-community/regexpp/-/regexpp-4.12.1.tgz", + "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^12.0.0 || ^14.0.0 || >=16.0.0" + } + }, + "node_modules/@eslint/config-array": { + "version": "0.18.0", + "resolved": "https://registry.npmjs.org/@eslint/config-array/-/config-array-0.18.0.tgz", + "integrity": "sha512-fTxvnS1sRMu3+JjXwJG0j/i4RT9u4qJ+lqS/yCGap4lH4zZGzQ7tu+xZqQmcMZq5OBZDL4QRxQzRjkWcGt8IVw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@eslint/object-schema": "^2.1.4", + "debug": "^4.3.1", + "minimatch": "^3.1.2" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/core": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/@eslint/core/-/core-0.7.0.tgz", + "integrity": "sha512-xp5Jirz5DyPYlPiKat8jaq0EmYvDXKKpzTbxXMpT9eqlRJkRKIz9AGMdlvYjih+im+QlhWrpvVjl8IPC/lHlUw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/eslintrc": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@eslint/eslintrc/-/eslintrc-3.1.0.tgz", + "integrity": "sha512-4Bfj15dVJdoy3RfZmmo86RK1Fwzn6SstsvK9JS+BaVKqC6QQQQyXekNaC+g+LKNgkQ+2VhGAzm6hO40AhMR3zQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ajv": "^6.12.4", + "debug": "^4.3.2", + "espree": "^10.0.1", + "globals": "^14.0.0", + "ignore": "^5.2.0", + "import-fresh": "^3.2.1", + "js-yaml": "^4.1.0", + "minimatch": "^3.1.2", + "strip-json-comments": "^3.1.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/@eslint/eslintrc/node_modules/argparse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", + "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", + "dev": true, + "license": "Python-2.0" + }, + "node_modules/@eslint/eslintrc/node_modules/globals": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-14.0.0.tgz", + "integrity": "sha512-oahGvuMGQlPw/ivIYBjVSrWAfWLBeku5tpPE2fOPLi+WHffIWbuh2tCjhyQhTBPMf5E9jDEH4FOmTYgYwbKwtQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/eslintrc/node_modules/js-yaml": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", + "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", + "dev": true, + "license": "MIT", + "dependencies": { + "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" + } + }, + "node_modules/@eslint/eslintrc/node_modules/strip-json-comments": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", + "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@eslint/js": { + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/@eslint/js/-/js-9.14.0.tgz", + "integrity": "sha512-pFoEtFWCPyDOl+C6Ift+wC7Ro89otjigCf5vcuWqWgqNSQbRrpjSvdeE6ofLz4dHmyxD5f7gIdGT4+p36L6Twg==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/object-schema": { + "version": "2.1.4", + "resolved": "https://registry.npmjs.org/@eslint/object-schema/-/object-schema-2.1.4.tgz", + "integrity": "sha512-BsWiH1yFGjXXS2yvrf5LyuoSIIbPrGUWob917o+BTKuZ7qJdxX8aJLRxs1fS9n6r7vESrq1OUqb68dANcFXuQQ==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/@eslint/plugin-kit": { + "version": "0.2.2", + "resolved": "https://registry.npmjs.org/@eslint/plugin-kit/-/plugin-kit-0.2.2.tgz", + "integrity": "sha512-CXtq5nR4Su+2I47WPOlWud98Y5Lv8Kyxp2ukhgFx/eW6Blm18VXJO5WuQylPugRo8nbluoi6GvvxBLqHcvqUUw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "levn": "^0.4.1" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, "node_modules/@gar/promisify": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/@gar/promisify/-/promisify-1.1.3.tgz", @@ -823,6 +1007,72 @@ "license": "MIT", "optional": true }, + "node_modules/@humanfs/core": { + "version": "0.19.1", + "resolved": "https://registry.npmjs.org/@humanfs/core/-/core-0.19.1.tgz", + "integrity": "sha512-5DyQ4+1JEUzejeK1JGICcideyfUbGixgS9jNgex5nqkW+cY7WZhxBigmieN5Qnw9ZosSNVC9KQKyb+GUaGyKUA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node": { + "version": "0.16.6", + "resolved": "https://registry.npmjs.org/@humanfs/node/-/node-0.16.6.tgz", + "integrity": "sha512-YuI2ZHQL78Q5HbhDiBA1X4LmYdXCKCMQIfw0pw7piHJwyREFebJUvrQN4cMssyES6x+vfUbx1CIpaQUKYdQZOw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@humanfs/core": "^0.19.1", + "@humanwhocodes/retry": "^0.3.0" + }, + "engines": { + "node": ">=18.18.0" + } + }, + "node_modules/@humanfs/node/node_modules/@humanwhocodes/retry": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.3.1.tgz", + "integrity": "sha512-JBxkERygn7Bv/GbN5Rv8Ul6LVknS+5Bp6RgDC/O8gEBU/yeH5Ui5C/OlWrTb6qct7LjjfT6Re2NxB0ln0yYybA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/module-importer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@humanwhocodes/module-importer/-/module-importer-1.0.1.tgz", + "integrity": "sha512-bxveV4V8v5Yb4ncFTT3rPSgZBOpCkjfK0y4oVVVJwIuDVBRMDXrPyXRL988i5ap9m9bnyEEjWfm5WkBmtffLfA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.22" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, + "node_modules/@humanwhocodes/retry": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@humanwhocodes/retry/-/retry-0.4.0.tgz", + "integrity": "sha512-xnRgu9DxZbkWak/te3fcytNyp8MTbuiZIaueg2rgEvBuN55n04nwLYLU9TX/VVlusc9L2ZNXi99nUFNkHXtr5g==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18.18" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/nzakas" + } + }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", @@ -1241,6 +1491,44 @@ "@jridgewell/sourcemap-codec": "^1.4.14" } }, + "node_modules/@nodelib/fs.scandir": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", + "integrity": "sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "2.0.5", + "run-parallel": "^1.1.9" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.stat": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz", + "integrity": "sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, + "node_modules/@nodelib/fs.walk": { + "version": "1.2.8", + "resolved": "https://registry.npmjs.org/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz", + "integrity": "sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.scandir": "2.1.5", + "fastq": "^1.6.0" + }, + "engines": { + "node": ">= 8" + } + }, "node_modules/@npmcli/fs": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/@npmcli/fs/-/fs-1.1.1.tgz", @@ -1382,6 +1670,13 @@ "@babel/types": "^7.20.7" } }, + "node_modules/@types/estree": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/graceful-fs": { "version": "4.1.9", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.9.tgz", @@ -1430,6 +1725,13 @@ "pretty-format": "^29.0.0" } }, + "node_modules/@types/json-schema": { + "version": "7.0.15", + "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", + "integrity": "sha512-5+fP8P8MFNC+AyZCDxrB2pkZFPGzqQWUzpSeuuVLvm8VMcorNYavBqoFcxK8bQz4Qsbn4oUEEem4wDLfcysGHA==", + "dev": true, + "license": "MIT" + }, "node_modules/@types/node": { "version": "22.7.8", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.7.8.tgz", @@ -1472,6 +1774,147 @@ "dev": true, "license": "MIT" }, + "node_modules/@typescript-eslint/scope-manager": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.13.0.tgz", + "integrity": "sha512-XsGWww0odcUT0gJoBZ1DeulY1+jkaHUciUq4jKNv4cpInbvvrtDoyBH9rE/n2V29wQJPk8iCH1wipra9BhmiMA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.13.0", + "@typescript-eslint/visitor-keys": "8.13.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/types": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.13.0.tgz", + "integrity": "sha512-4cyFErJetFLckcThRUFdReWJjVsPCqyBlJTi6IDEpc1GWCIIZRFxVppjWLIMcQhNGhdWJJRYFHpHoDWvMlDzng==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/typescript-estree": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.13.0.tgz", + "integrity": "sha512-v7SCIGmVsRK2Cy/LTLGN22uea6SaUIlpBcO/gnMGT/7zPtxp90bphcGf4fyrCQl3ZtiBKqVTG32hb668oIYy1g==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "@typescript-eslint/types": "8.13.0", + "@typescript-eslint/visitor-keys": "8.13.0", + "debug": "^4.3.4", + "fast-glob": "^3.3.2", + "is-glob": "^4.0.3", + "minimatch": "^9.0.4", + "semver": "^7.6.0", + "ts-api-utils": "^1.3.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependenciesMeta": { + "typescript": { + "optional": true + } + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@typescript-eslint/typescript-estree/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@typescript-eslint/utils": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.13.0.tgz", + "integrity": "sha512-A1EeYOND6Uv250nybnLZapeXpYMl8tkzYUxqmoKAWnI4sei3ihf2XdZVd+vVOmHGcp3t+P7yRrNsyyiXTvShFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.4.0", + "@typescript-eslint/scope-manager": "8.13.0", + "@typescript-eslint/types": "8.13.0", + "@typescript-eslint/typescript-estree": "8.13.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + }, + "peerDependencies": { + "eslint": "^8.57.0 || ^9.0.0" + } + }, + "node_modules/@typescript-eslint/visitor-keys": { + "version": "8.13.0", + "resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.13.0.tgz", + "integrity": "sha512-7N/+lztJqH4Mrf0lb10R/CbI1EaAMMGyF5y0oJvFoAhafwgiRA7TXyd8TFn8FC8k5y2dTsYogg238qavRGNnlw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/types": "8.13.0", + "eslint-visitor-keys": "^3.4.3" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/typescript-eslint" + } + }, + "node_modules/@typescript-eslint/visitor-keys/node_modules/eslint-visitor-keys": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-3.4.3.tgz", + "integrity": "sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/@vladfrangu/async_event_emitter": { "version": "2.4.6", "resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.4.6.tgz", @@ -1499,6 +1942,29 @@ "license": "ISC", "optional": true }, + "node_modules/acorn": { + "version": "8.14.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", + "integrity": "sha512-cl669nCJTZBsL97OF4kUQm5g5hC2uihk0NxY3WENAC0TYdILVkAyHymAntgxGkl7K+t0cXIrH5siy5S4XkFycA==", + "dev": true, + "license": "MIT", + "bin": { + "acorn": "bin/acorn" + }, + "engines": { + "node": ">=0.4.0" + } + }, + "node_modules/acorn-jsx": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", + "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", + "dev": true, + "license": "MIT", + "peerDependencies": { + "acorn": "^6.0.0 || ^7.0.0 || ^8.0.0" + } + }, "node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", @@ -1539,6 +2005,23 @@ "node": ">=8" } }, + "node_modules/ajv": { + "version": "6.12.6", + "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.12.6.tgz", + "integrity": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", + "dev": true, + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.1", + "fast-json-stable-stringify": "^2.0.0", + "json-schema-traverse": "^0.4.1", + "uri-js": "^4.2.2" + }, + "funding": { + "type": "github", + "url": "https://github.com/sponsors/epoberezkin" + } + }, "node_modules/ansi-escapes": { "version": "4.3.2", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.2.tgz", @@ -2265,6 +2748,13 @@ "node": ">=4.0.0" } }, + "node_modules/deep-is": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.4.tgz", + "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", + "dev": true, + "license": "MIT" + }, "node_modules/deepmerge": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", @@ -2461,6 +2951,203 @@ "node": ">=8" } }, + "node_modules/eslint": { + "version": "9.14.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-9.14.0.tgz", + "integrity": "sha512-c2FHsVBr87lnUtjP4Yhvk4yEhKrQavGafRA/Se1ouse8PfbfC/Qh9Mxa00yWsZRlqeUB9raXip0aiiUZkgnr9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@eslint-community/eslint-utils": "^4.2.0", + "@eslint-community/regexpp": "^4.12.1", + "@eslint/config-array": "^0.18.0", + "@eslint/core": "^0.7.0", + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "9.14.0", + "@eslint/plugin-kit": "^0.2.0", + "@humanfs/node": "^0.16.6", + "@humanwhocodes/module-importer": "^1.0.1", + "@humanwhocodes/retry": "^0.4.0", + "@types/estree": "^1.0.6", + "@types/json-schema": "^7.0.15", + "ajv": "^6.12.4", + "chalk": "^4.0.0", + "cross-spawn": "^7.0.2", + "debug": "^4.3.2", + "escape-string-regexp": "^4.0.0", + "eslint-scope": "^8.2.0", + "eslint-visitor-keys": "^4.2.0", + "espree": "^10.3.0", + "esquery": "^1.5.0", + "esutils": "^2.0.2", + "fast-deep-equal": "^3.1.3", + "file-entry-cache": "^8.0.0", + "find-up": "^5.0.0", + "glob-parent": "^6.0.2", + "ignore": "^5.2.0", + "imurmurhash": "^0.1.4", + "is-glob": "^4.0.0", + "json-stable-stringify-without-jsonify": "^1.0.1", + "lodash.merge": "^4.6.2", + "minimatch": "^3.1.2", + "natural-compare": "^1.4.0", + "optionator": "^0.9.3", + "text-table": "^0.2.0" + }, + "bin": { + "eslint": "bin/eslint.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://eslint.org/donate" + }, + "peerDependencies": { + "jiti": "*" + }, + "peerDependenciesMeta": { + "jiti": { + "optional": true + } + } + }, + "node_modules/eslint-plugin-jest": { + "version": "28.8.3", + "resolved": "https://registry.npmjs.org/eslint-plugin-jest/-/eslint-plugin-jest-28.8.3.tgz", + "integrity": "sha512-HIQ3t9hASLKm2IhIOqnu+ifw7uLZkIlR7RYNv7fMcEi/p0CIiJmfriStQS2LDkgtY4nyLbIZAD+JL347Yc2ETQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@typescript-eslint/utils": "^6.0.0 || ^7.0.0 || ^8.0.0" + }, + "engines": { + "node": "^16.10.0 || ^18.12.0 || >=20.0.0" + }, + "peerDependencies": { + "@typescript-eslint/eslint-plugin": "^6.0.0 || ^7.0.0 || ^8.0.0", + "eslint": "^7.0.0 || ^8.0.0 || ^9.0.0", + "jest": "*" + }, + "peerDependenciesMeta": { + "@typescript-eslint/eslint-plugin": { + "optional": true + }, + "jest": { + "optional": true + } + } + }, + "node_modules/eslint-scope": { + "version": "8.2.0", + "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-8.2.0.tgz", + "integrity": "sha512-PHlWUfG6lvPc3yvP5A4PNyBL1W8fkDUccmI21JUu/+GKZBoH/W5u6usENXUrWFRsyoW5ACUjFGgAFQp5gUlb/A==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "esrecurse": "^4.3.0", + "estraverse": "^5.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint-visitor-keys": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.0.tgz", + "integrity": "sha512-UyLnSehNt62FFhSwjZlHmeokpRK59rcz29j+F1/aDgbkbRTk7wIc9XzdoasMUbRNKDM0qQt/+BJ4BrpFeABemw==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, + "node_modules/eslint/node_modules/escape-string-regexp": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", + "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/find-up": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", + "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", + "dev": true, + "license": "MIT", + "dependencies": { + "locate-path": "^6.0.0", + "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/locate-path": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", + "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/eslint/node_modules/p-locate": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", + "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", + "dev": true, + "license": "MIT", + "dependencies": { + "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/espree": { + "version": "10.3.0", + "resolved": "https://registry.npmjs.org/espree/-/espree-10.3.0.tgz", + "integrity": "sha512-0QYC8b24HWY8zjRnDTL6RiHfDbAWn63qb4LMj1Z4b076A4une81+z03Kg7l7mn/48PUTqoLptSXez8oknU8Clg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "acorn": "^8.14.0", + "acorn-jsx": "^5.3.2", + "eslint-visitor-keys": "^4.2.0" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + }, + "funding": { + "url": "https://opencollective.com/eslint" + } + }, "node_modules/esprima": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz", @@ -2475,6 +3162,52 @@ "node": ">=4" } }, + "node_modules/esquery": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz", + "integrity": "sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "estraverse": "^5.1.0" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/esrecurse": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/esrecurse/-/esrecurse-4.3.0.tgz", + "integrity": "sha512-KmfKL3b6G+RXvP8N1vr3Tq1kL/oCFgn2NYXEtqP8/L3pKapUA4G8cFVaoF3SU323CD4XypR/ffioHmkti6/Tag==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "estraverse": "^5.2.0" + }, + "engines": { + "node": ">=4.0" + } + }, + "node_modules/estraverse": { + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-5.3.0.tgz", + "integrity": "sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==", + "dev": true, + "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==", + "dev": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/execa": { "version": "5.1.1", "resolved": "https://registry.npmjs.org/execa/-/execa-5.1.1.tgz", @@ -2540,6 +3273,36 @@ "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", "license": "MIT" }, + "node_modules/fast-glob": { + "version": "3.3.2", + "resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.3.2.tgz", + "integrity": "sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==", + "dev": true, + "license": "MIT", + "dependencies": { + "@nodelib/fs.stat": "^2.0.2", + "@nodelib/fs.walk": "^1.2.3", + "glob-parent": "^5.1.2", + "merge2": "^1.3.0", + "micromatch": "^4.0.4" + }, + "engines": { + "node": ">=8.6.0" + } + }, + "node_modules/fast-glob/node_modules/glob-parent": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", + "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/fast-json-stable-stringify": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz", @@ -2547,6 +3310,23 @@ "dev": true, "license": "MIT" }, + "node_modules/fast-levenshtein": { + "version": "2.0.6", + "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", + "integrity": "sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==", + "dev": true, + "license": "MIT" + }, + "node_modules/fastq": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/fastq/-/fastq-1.17.1.tgz", + "integrity": "sha512-sRVD3lWVIXWg6By68ZN7vho9a1pQcN/WBFaAAsDDFzlJjvoGx0P8z7V1t72grFJfJhu3YPZBuu25f7Kaw2jN1w==", + "dev": true, + "license": "ISC", + "dependencies": { + "reusify": "^1.0.4" + } + }, "node_modules/fb-watchman": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/fb-watchman/-/fb-watchman-2.0.2.tgz", @@ -2557,6 +3337,19 @@ "bser": "2.1.1" } }, + "node_modules/file-entry-cache": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/file-entry-cache/-/file-entry-cache-8.0.0.tgz", + "integrity": "sha512-XXTUwCvisa5oacNGRP9SfNtYBNAMi+RPwBFmblZEF7N7swHYQS6/Zfk7SRwx4D5j3CH211YNRco1DEMNVfZCnQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "flat-cache": "^4.0.0" + }, + "engines": { + "node": ">=16.0.0" + } + }, "node_modules/file-uri-to-path": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz", @@ -2590,6 +3383,27 @@ "node": ">=8" } }, + "node_modules/flat-cache": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/flat-cache/-/flat-cache-4.0.1.tgz", + "integrity": "sha512-f7ccFPK3SXFHpx15UIGyRJ/FJQctuKZ0zVuN3frBo4HnK3cay9VEW0R6yPYFHC0AgqhukPzKjq22t5DmAyqGyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "flatted": "^3.2.9", + "keyv": "^4.5.4" + }, + "engines": { + "node": ">=16" + } + }, + "node_modules/flatted": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/flatted/-/flatted-3.3.1.tgz", + "integrity": "sha512-X8cqMLLie7KsNUDSdzeN8FYK9rEt4Dt67OsG/DNGnYTSDBG4uFAJFBnUeiV+zCVAvwFy56IjM9sH51jVaEhNxw==", + "dev": true, + "license": "ISC" + }, "node_modules/fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", @@ -2755,14 +3569,30 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/glob-parent": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", + "integrity": "sha512-XxwI8EOhVQgWp6iDL+3b0r86f4d6AX6zSU55HfB4ydCEuXLXc5FcYeOu+nnGftS4TEju/11rt4KJPTMgbfmv4A==", + "dev": true, + "license": "ISC", + "dependencies": { + "is-glob": "^4.0.3" + }, + "engines": { + "node": ">=10.13.0" + } + }, "node_modules/globals": { - "version": "11.12.0", - "resolved": "https://registry.npmjs.org/globals/-/globals-11.12.0.tgz", - "integrity": "sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==", + "version": "15.12.0", + "resolved": "https://registry.npmjs.org/globals/-/globals-15.12.0.tgz", + "integrity": "sha512-1+gLErljJFhbOVyaetcwJiJ4+eLe45S2E7P5UiZ9xGfeq3ATQf5DOv9G7MH3gGbKQLkzmNh2DxfZwLdw+j6oTQ==", "dev": true, "license": "MIT", "engines": { - "node": ">=4" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, "node_modules/graceful-fs": { @@ -2885,6 +3715,43 @@ ], "license": "BSD-3-Clause" }, + "node_modules/ignore": { + "version": "5.3.2", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", + "integrity": "sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 4" + } + }, + "node_modules/import-fresh": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/import-fresh/-/import-fresh-3.3.0.tgz", + "integrity": "sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "parent-module": "^1.0.0", + "resolve-from": "^4.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/import-fresh/node_modules/resolve-from": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", + "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/import-local": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/import-local/-/import-local-3.2.0.tgz", @@ -2993,6 +3860,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -3013,6 +3890,19 @@ "node": ">=6" } }, + "node_modules/is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/is-lambda": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-lambda/-/is-lambda-1.0.1.tgz", @@ -3758,6 +4648,13 @@ "node": ">=6" } }, + "node_modules/json-buffer": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/json-buffer/-/json-buffer-3.0.1.tgz", + "integrity": "sha512-4bV5BfR2mqfQTJm+V5tPPdf+ZpuhiIvTuAB5g8kcrXOZpTT/QwwVRWBywX1ozr6lEuPdbHxwaJlm9G6mI2sfSQ==", + "dev": true, + "license": "MIT" + }, "node_modules/json-parse-even-better-errors": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/json-parse-even-better-errors/-/json-parse-even-better-errors-2.3.1.tgz", @@ -3765,6 +4662,20 @@ "dev": true, "license": "MIT" }, + "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==", + "dev": true, + "license": "MIT" + }, + "node_modules/json-stable-stringify-without-jsonify": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz", + "integrity": "sha512-Bdboy+l7tA3OGW6FjyFHWkP5LuByj1Tk33Ljyq0axyzdk9//JSi2u3fP1QSmd1KNwq6VOKYGlAu87CisVir6Pw==", + "dev": true, + "license": "MIT" + }, "node_modules/json5": { "version": "2.2.3", "resolved": "https://registry.npmjs.org/json5/-/json5-2.2.3.tgz", @@ -3778,6 +4689,16 @@ "node": ">=6" } }, + "node_modules/keyv": { + "version": "4.5.4", + "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", + "integrity": "sha512-oxVHkHR/EJf2CNXnWxRLW6mg7JyCCUcG0DtEGmL2ctUo1PNTin1PUil+r/+4r5MpVgC/fn1kjsx7mjSujKqIpw==", + "dev": true, + "license": "MIT", + "dependencies": { + "json-buffer": "3.0.1" + } + }, "node_modules/kleur": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/kleur/-/kleur-3.0.3.tgz", @@ -3798,6 +4719,20 @@ "node": ">=6" } }, + "node_modules/levn": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/levn/-/levn-0.4.1.tgz", + "integrity": "sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1", + "type-check": "~0.4.0" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/lines-and-columns": { "version": "1.2.4", "resolved": "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.2.4.tgz", @@ -3824,6 +4759,13 @@ "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", "license": "MIT" }, + "node_modules/lodash.merge": { + "version": "4.6.2", + "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", + "integrity": "sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==", + "dev": true, + "license": "MIT" + }, "node_modules/lodash.snakecase": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz", @@ -3910,6 +4852,16 @@ "dev": true, "license": "MIT" }, + "node_modules/merge2": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/merge2/-/merge2-1.4.1.tgz", + "integrity": "sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 8" + } + }, "node_modules/micromatch": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz", @@ -4249,6 +5201,24 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/optionator": { + "version": "0.9.4", + "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.9.4.tgz", + "integrity": "sha512-6IpQ7mKUxRcZNLIObR0hz7lxsapSSIYNZJwXPGeF0mTVqGKFIXj1DQcMoT22S3ROcLyY/rz0PWaWZ9ayWmad9g==", + "dev": true, + "license": "MIT", + "dependencies": { + "deep-is": "^0.1.3", + "fast-levenshtein": "^2.0.6", + "levn": "^0.4.1", + "prelude-ls": "^1.2.1", + "type-check": "^0.4.0", + "word-wrap": "^1.2.5" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", @@ -4320,6 +5290,19 @@ "node": ">=6" } }, + "node_modules/parent-module": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/parent-module/-/parent-module-1.0.1.tgz", + "integrity": "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==", + "dev": true, + "license": "MIT", + "dependencies": { + "callsites": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/parse-json": { "version": "5.2.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.2.0.tgz", @@ -4445,6 +5428,16 @@ "node": ">=10" } }, + "node_modules/prelude-ls": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.2.1.tgz", + "integrity": "sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/pretty-format": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-29.7.0.tgz", @@ -4518,6 +5511,16 @@ "once": "^1.3.1" } }, + "node_modules/punycode": { + "version": "2.3.1", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz", + "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, "node_modules/pure-rand": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.1.0.tgz", @@ -4535,6 +5538,27 @@ ], "license": "MIT" }, + "node_modules/queue-microtask": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", + "integrity": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT" + }, "node_modules/random-item": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/random-item/-/random-item-1.0.0.tgz", @@ -4646,6 +5670,17 @@ "node": ">= 4" } }, + "node_modules/reusify": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/reusify/-/reusify-1.0.4.tgz", + "integrity": "sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==", + "dev": true, + "license": "MIT", + "engines": { + "iojs": ">=1.0.0", + "node": ">=0.10.0" + } + }, "node_modules/rimraf": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", @@ -4663,6 +5698,30 @@ "url": "https://github.com/sponsors/isaacs" } }, + "node_modules/run-parallel": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", + "integrity": "sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "license": "MIT", + "dependencies": { + "queue-microtask": "^1.2.2" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -5160,6 +6219,13 @@ "node": ">=8" } }, + "node_modules/text-table": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", + "integrity": "sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==", + "dev": true, + "license": "MIT" + }, "node_modules/tmpl": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/tmpl/-/tmpl-1.0.5.tgz", @@ -5190,6 +6256,19 @@ "node": ">=8.0" } }, + "node_modules/ts-api-utils": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-1.4.0.tgz", + "integrity": "sha512-032cPxaEKwM+GT3vA5JXNzIaizx388rhsSW79vGRNGXfRRAdEAn2mvk36PvK5HnOchyWZ7afLEXqYCvPCrzuzQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "typescript": ">=4.2.0" + } + }, "node_modules/ts-mixer": { "version": "6.0.4", "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.4.tgz", @@ -5214,6 +6293,19 @@ "node": "*" } }, + "node_modules/type-check": { + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", + "integrity": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", + "dev": true, + "license": "MIT", + "dependencies": { + "prelude-ls": "^1.2.1" + }, + "engines": { + "node": ">= 0.8.0" + } + }, "node_modules/type-detect": { "version": "4.0.8", "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", @@ -5237,6 +6329,21 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typescript": { + "version": "5.6.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.6.3.tgz", + "integrity": "sha512-hjcS1mhfuyi4WW8IWtjP7brDrG2cuDZukyrYrSauoXGNgx0S7zceP07adYkJycEr56BOUTNPzbInooiN3fn1qw==", + "dev": true, + "license": "Apache-2.0", + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/undici": { "version": "6.19.8", "resolved": "https://registry.npmjs.org/undici/-/undici-6.19.8.tgz", @@ -5303,6 +6410,16 @@ "browserslist": ">= 4.21.0" } }, + "node_modules/uri-js": { + "version": "4.4.1", + "resolved": "https://registry.npmjs.org/uri-js/-/uri-js-4.4.1.tgz", + "integrity": "sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "punycode": "^2.1.0" + } + }, "node_modules/util-deprecate": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", @@ -5360,6 +6477,16 @@ "string-width": "^1.0.2 || 2 || 3 || 4" } }, + "node_modules/word-wrap": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/word-wrap/-/word-wrap-1.2.5.tgz", + "integrity": "sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", diff --git a/package.json b/package.json index 438d42c..2d46cd0 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,8 @@ "sqlite3": "^5.1.6" }, "scripts": { - "test": "jest" + "test": "jest", + "lint": "npx eslint ." }, "repository": { "type": "git", @@ -20,7 +21,11 @@ "author": "SileNce5k", "license": "UNLICENSE", "devDependencies": { + "@eslint/js": "^9.14.0", "@types/jest": "^29.5.14", + "eslint": "^9.14.0", + "eslint-plugin-jest": "^28.8.3", + "globals": "^15.12.0", "jest": "^29.7.0" } } From a3e9e1f90cd2426336ea9252fd5027e44b33216b Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 5 Nov 2024 06:07:51 +0100 Subject: [PATCH 03/15] Add count subcommand to custom command Use scopes in each case in the switch statement --- commands/misc/custom.js | 39 ++++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/commands/misc/custom.js b/commands/misc/custom.js index f684b3b..e39ffb8 100644 --- a/commands/misc/custom.js +++ b/commands/misc/custom.js @@ -17,7 +17,8 @@ module.exports = { "custom remove - Delete your custom commands.", "custom owner - check owner of custom command", "custom list - list all custom commands", - "custom variables - list all variables you can use" + "custom variables - list all variables you can use", + "custom count - display the amount of custom commands" ], execute({message, args, client, prefix, owners}) { const customPath = 'data/customCommands.json'; @@ -31,18 +32,20 @@ module.exports = { let customMessage = args.slice(2, args.length).join(" "); switch (args[0].toLowerCase()) { - case "add": + case "add":{ if(!customMessage) { message.channel.send("Message can't be empty"); return; } sendText = addCustomCommand(customName, customMessage, message.author.id); break; + } case "remove": - case "delete": + case "delete":{ sendText = deleteCustomCommand(customName, message.author.id, owners); break; - case "owner": + } + case "owner":{ let author = getOwnerOfCustomCommand(customName); let user; if(!author) @@ -55,10 +58,11 @@ module.exports = { } break; - case "list": + } + case "list": { const embed = new EmbedBuilder(); sendText = getAllCustomCommands(); - if(sendText != ""){ + if(sendText !== ""){ embed.setColor(15780145) embed.addFields( { name: "Custom commands", value: sendText }, @@ -67,13 +71,16 @@ module.exports = { isEmbed = true; }else sendText = "NO CUSTOM COMMANDS" break; - case "variables": + } + case "variables": { sendText = "The variables you can use are:\n\n\n\n\n\n\n" break; - case "edit": + } + case "edit": { sendText = editCustomCommand(customName, message.author.id, customMessage) break; - case "show": + } + case "show": { let json = fs.readFileSync(customPath, 'utf8'); let customCommands = JSON.parse(json) sendText = "Command not found." @@ -83,12 +90,22 @@ module.exports = { } }); break; - case "rename": + } + case "rename": { sendText = renameCustomCommand(customName, args[2], message.author.id); break; - default: + } + case "count": { + const customPath = './data/customCommands.json'; + let json = fs.readFileSync(customPath, 'utf8'); + let customCommands = JSON.parse(json) + sendText = `There are ${customCommands.length} custom commands in total`; + break; + } + default: { sendText = `Argument not recognized.\n"${prefix}help custom" to see all arguments you can use.` break; + } } } if(isEmbed) message.channel.send({embeds :[sendText]}) From 34c5f088062712ea7e304430c8985914525e62a9 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 5 Nov 2024 06:09:50 +0100 Subject: [PATCH 04/15] Use scopes on switch cases --- commands/misc/timer.js | 15 ++++++++++----- util/morePresence.js | 18 ++++++++++++------ 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/commands/misc/timer.js b/commands/misc/timer.js index 746689b..cecbebb 100644 --- a/commands/misc/timer.js +++ b/commands/misc/timer.js @@ -17,21 +17,25 @@ module.exports = { let sendText = "This should never happen."; switch (args[0]) { case "add": - case "create": + case "create": { sendText = await createTimer(message, args, false); break; - case "edit": + } + case "edit": { sendText = "not implemented yet" break; + } case "delete": - case "remove": + case "remove": { let timerID = args[1]; sendText = await deleteTimer(message.author.id, timerID); break; - case "show": + } + case "show": { sendText = await showTimer(message.author.id, args[1]); break; - default: + } + default: { sendText = "not sure what you mean"; if(args.length < 2){ sendText = "Please specify a time, and a message to send after the timer has finished"; @@ -40,6 +44,7 @@ module.exports = { if(!isNaN(parseTime(args[0], Math.floor(new Date() / 1000)))) sendText = await createTimer(message, args, true); break; + } } message.channel.send(sendText); } diff --git a/util/morePresence.js b/util/morePresence.js index 96b3189..0368484 100644 --- a/util/morePresence.js +++ b/util/morePresence.js @@ -1,34 +1,40 @@ module.exports = function (user) { let details; switch (user.presence.activities[0].name) { - case "foobar2000": + case "foobar2000": { let artist = user.presence.activities[0].state.split(":")[0]; let album = user.presence.activities[0].state.split(":")[1].slice(1); details = `Artist: ${artist}\nAlbum: ${album}\nSong: ${user.presence.activities[0].details}\n` break; - case "Apple Music": + } + case "Apple Music": { details = `Artist/Song: ${user.presence.activities[0].details} \nAlbum: ${user.presence.activities[0].state}\n` break; - case "Spotify": + } + case "Spotify": { details = `Artist: ${user.presence.activities[0].state}\nAlbum: ${user.presence.activities[0].details}\nSong: ${user.presence.activities[0].assets.largeText}\n` break; - case "Custom Status": + } + case "Custom Status": { if(user.presence.activities[0].state !== null) details = `"${user.presence.activities[0].state}"\n` else details = ""; break; - case "Code": + } + case "Code": { if(user.presence.activities[0].details != null) if(user.presence.activities[0].details.slice(0, 7) === "Editing") details = `Workspace: ${user.presence.activities[0].state}\nEditing: ${user.presence.activities[0].details.slice(8)}\n` else details = `Workspace: ${user.presence.activities[0].state}\n${user.presence.activities[0].details}\n` break; - default: + } + default: { details = 0; break; + } } return details From b89b926f9a327100027ceb7c069b549c78be9f37 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 5 Nov 2024 06:13:21 +0100 Subject: [PATCH 05/15] Update actions/checkout to v4 --- .github/workflows/njsscan.yml | 2 +- commands/info/help.js | 3 --- commands/misc/emoji.js | 3 ++- server/ready.js | 3 ++- util/lastfm/getCurrentCover.js | 1 + util/lastfm/getCurrentScrobble.js | 1 + util/reloadCommands.js | 1 - util/timer/checkTimer.js | 1 - util/timer/convertJSONToSQL.js | 1 - util/timer/createTimer.js | 1 - util/timer/parseTime.js | 6 +++--- 11 files changed, 10 insertions(+), 13 deletions(-) diff --git a/.github/workflows/njsscan.yml b/.github/workflows/njsscan.yml index ff888b4..45de787 100644 --- a/.github/workflows/njsscan.yml +++ b/.github/workflows/njsscan.yml @@ -30,7 +30,7 @@ jobs: name: njsscan code scanning steps: - name: Checkout the code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: nodejsscan scan id: njsscan uses: ajinabraham/njsscan-action@v7 diff --git a/commands/info/help.js b/commands/info/help.js index 6174e26..e88df47 100644 --- a/commands/info/help.js +++ b/commands/info/help.js @@ -1,4 +1,3 @@ -const fs = require('fs'); const {EmbedBuilder} = require('discord.js'); const getSubdirFiles = require('../../util/getSubdirFiles'); @@ -17,7 +16,6 @@ module.exports = { let fieldName = `Page [[page]]/${Math.round(client.commands.size / 10)}`; let iteration = 0; let num_in_args = false; - let added_commands = 0; let page = -1; @@ -53,7 +51,6 @@ module.exports = { if (!command.admin){ if(start < iteration){ }else{ - added_commands++ commands = commands + `${prefix}${command.name} | ${command.description}\n`; iteration++ } diff --git a/commands/misc/emoji.js b/commands/misc/emoji.js index 6ce12dc..58befa8 100644 --- a/commands/misc/emoji.js +++ b/commands/misc/emoji.js @@ -19,7 +19,8 @@ module.exports = { try { num = num.slice(0, -1); } catch (e) { - message.channel.send("There was an error."); + console.error(e) + message.channel.send("There was an error. Check the logs"); return; } message.channel.send("https://cdn.discordapp.com/emojis/" + num + extension); diff --git a/server/ready.js b/server/ready.js index 20324b7..b65e8ff 100644 --- a/server/ready.js +++ b/server/ready.js @@ -9,7 +9,8 @@ module.exports = function(client, enableLoginMessage, loginChannel, loginMessage try{ client.channels.cache.get(loginChannel).send(loginMessage) }catch(err){ - console.log("Failed trying to send a message on login.\n") + console.error("Failed trying to send a message on login.\n") + console.error(err) } loadServerPrefixes(client) checkTimer(client); diff --git a/util/lastfm/getCurrentCover.js b/util/lastfm/getCurrentCover.js index bc4224c..16a1b98 100644 --- a/util/lastfm/getCurrentCover.js +++ b/util/lastfm/getCurrentCover.js @@ -25,6 +25,7 @@ module.exports = async function(userID, guild) { try { track = data.recenttracks.track[0]; } catch (error) { + console.error(error); scrobble.error = true; switch(data.error){ case 6: diff --git a/util/lastfm/getCurrentScrobble.js b/util/lastfm/getCurrentScrobble.js index d1071ff..5c83bd5 100644 --- a/util/lastfm/getCurrentScrobble.js +++ b/util/lastfm/getCurrentScrobble.js @@ -39,6 +39,7 @@ module.exports = async function (userID, guild) { } resolve(tracks); } catch (error) { + console.error(error) let scrobble = {}; scrobble.error = true; if (data.error === 6) { diff --git a/util/reloadCommands.js b/util/reloadCommands.js index 025632e..6faad91 100644 --- a/util/reloadCommands.js +++ b/util/reloadCommands.js @@ -1,4 +1,3 @@ -const fs = require('fs'); const getSubdirFiles = require('./getSubdirFiles'); const commandPath = 'commands/' const utilPath = 'util/' diff --git a/util/timer/checkTimer.js b/util/timer/checkTimer.js index 1bea13b..8902f5c 100644 --- a/util/timer/checkTimer.js +++ b/util/timer/checkTimer.js @@ -1,5 +1,4 @@ const sendTimerReminder = require('./sendTimerReminder') -const fs = require('fs') const sqlite3 = require('sqlite3').verbose(); module.exports = async function (client) { const checkTimer = require('./checkTimer') diff --git a/util/timer/convertJSONToSQL.js b/util/timer/convertJSONToSQL.js index efa1bed..ad3d2d5 100644 --- a/util/timer/convertJSONToSQL.js +++ b/util/timer/convertJSONToSQL.js @@ -1,4 +1,3 @@ -const fs = require('fs'); const sqlite3 = require('sqlite3').verbose(); module.exports = async function () { const timers = require('../../data/timers.json') diff --git a/util/timer/createTimer.js b/util/timer/createTimer.js index 3910d09..4ff2fb4 100644 --- a/util/timer/createTimer.js +++ b/util/timer/createTimer.js @@ -1,4 +1,3 @@ -const fs = require('fs'); const parseTime = require('./parseTime'); const sqlite3 = require('sqlite3').verbose(); module.exports = async function (message, args, compatibility) { diff --git a/util/timer/parseTime.js b/util/timer/parseTime.js index 732fe80..e20dd99 100644 --- a/util/timer/parseTime.js +++ b/util/timer/parseTime.js @@ -30,9 +30,9 @@ module.exports = function(time, currentUnixTime){ -function getTime(time, currentUnixTime) { +// function getTime(time, currentUnixTime) { - return timeInSeconds; -} +// return timeInSeconds; +// } From aaa10cb57a66512c96c693afc8d6eaa0d487952d Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 5 Nov 2024 06:45:08 +0100 Subject: [PATCH 06/15] update actions/checkout and actions/setup-node to v4 --- .github/workflows/lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5f16ea2..fa657a3 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,10 +8,10 @@ jobs: steps: - name: Check out code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up Node.js - uses: actions/setup-node@v3 + uses: actions/setup-node@v4 with: node-version: 'latest' From 4b53d875e4d2e5c0b43df1ee2a99dacec8ba2ad0 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 5 Nov 2024 06:53:47 +0100 Subject: [PATCH 07/15] Remove njsscan workflow --- .github/workflows/njsscan.yml | 42 ----------------------------------- 1 file changed, 42 deletions(-) delete mode 100644 .github/workflows/njsscan.yml diff --git a/.github/workflows/njsscan.yml b/.github/workflows/njsscan.yml deleted file mode 100644 index 45de787..0000000 --- a/.github/workflows/njsscan.yml +++ /dev/null @@ -1,42 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. - -# This workflow integrates njsscan with GitHub's Code Scanning feature -# nodejsscan is a static security code scanner that finds insecure code patterns in your Node.js applications - -name: njsscan sarif - -on: - push: - branches: [ "master", "devbot" ] - pull_request: - # The branches below must be a subset of the branches above - branches: [ "master", "devbot" ] - schedule: - - cron: '43 12 * * 6' - -permissions: - contents: read - -jobs: - njsscan: - permissions: - contents: read # for actions/checkout to fetch code - security-events: write # for github/codeql-action/upload-sarif to upload SARIF results - actions: read # only required for a private repository by github/codeql-action/upload-sarif to get the Action run status - runs-on: ubuntu-latest - name: njsscan code scanning - steps: - - name: Checkout the code - uses: actions/checkout@v4 - - name: nodejsscan scan - id: njsscan - uses: ajinabraham/njsscan-action@v7 - with: - args: '. --sarif --output results.sarif || true' - - name: Upload njsscan report - uses: github/codeql-action/upload-sarif@v3 - with: - sarif_file: results.sarif From 5a4cfd0a5f44309e19cf8a79d67906784310bdb6 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Wed, 6 Nov 2024 01:44:16 +0100 Subject: [PATCH 08/15] Rename database table functions to be clearer --- server.js | 10 +++++----- server/{ => createDatabaseTables}/createLastfmTable.js | 0 .../createTimersTable.js} | 0 .../{convertJSONToSQL.js => convertTimerJSONToSQL.js} | 0 4 files changed, 5 insertions(+), 5 deletions(-) rename server/{ => createDatabaseTables}/createLastfmTable.js (100%) rename server/{createDatabaseTables.js => createDatabaseTables/createTimersTable.js} (100%) rename util/timer/{convertJSONToSQL.js => convertTimerJSONToSQL.js} (100%) diff --git a/server.js b/server.js index 3a4e316..f35e458 100644 --- a/server.js +++ b/server.js @@ -1,6 +1,6 @@ const fs = require('fs'); const createInitialConfig = require("./util/createInitialConfig") -const convertJSONToSQL = require('./util/timer/convertJSONToSQL'); +const convertTimerJSONToSQL = require('./util/timer/convertTimerJSONToSQL.js'); if(!fs.existsSync("./data/config.json")) { createInitialConfig(); } @@ -8,16 +8,16 @@ async function checkAndConvertJSONToSQL(){ process.stdout.write("Checking if timers.json exists... ") if(fs.existsSync("./data/timers.json")){ process.stdout.write(true + "\n") - await createDatabaseTables(); - await convertJSONToSQL(); + await createTimerTables(); + await convertTimerJSONToSQL(); fs.renameSync('data/timers.json', 'data/timers.json.old'); console.log("Renamed timers.json to timers.json.old"); }else{ process.stdout.write(false + "\n") } } -const createDatabaseTables = require('./server/createDatabaseTables'); -const createLastfmTable = require('./server/createLastfmTable'); +const createTimerTables = require('./server/createDatabaseTables/createTimersTable'); +const createLastfmTable = require('./server/createDatabaseTables/createLastfmTable'); createLastfmTable(); checkAndConvertJSONToSQL(); const { Collection, Client, GatewayIntentBits, Partials } = require('discord.js'); diff --git a/server/createLastfmTable.js b/server/createDatabaseTables/createLastfmTable.js similarity index 100% rename from server/createLastfmTable.js rename to server/createDatabaseTables/createLastfmTable.js diff --git a/server/createDatabaseTables.js b/server/createDatabaseTables/createTimersTable.js similarity index 100% rename from server/createDatabaseTables.js rename to server/createDatabaseTables/createTimersTable.js diff --git a/util/timer/convertJSONToSQL.js b/util/timer/convertTimerJSONToSQL.js similarity index 100% rename from util/timer/convertJSONToSQL.js rename to util/timer/convertTimerJSONToSQL.js From f28055e02405ed2f329f3aff407fda2bf1134968 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Wed, 6 Nov 2024 04:06:34 +0100 Subject: [PATCH 09/15] Refactor server.js --- server.js | 111 ++++++++++++++++++++++++++++++------------------------ 1 file changed, 62 insertions(+), 49 deletions(-) diff --git a/server.js b/server.js index f35e458..a4105c9 100644 --- a/server.js +++ b/server.js @@ -1,6 +1,7 @@ const fs = require('fs'); const createInitialConfig = require("./util/createInitialConfig") const convertTimerJSONToSQL = require('./util/timer/convertTimerJSONToSQL.js'); +const createTimersTable = require('./server/createDatabaseTables/createTimersTable'); if(!fs.existsSync("./data/config.json")) { createInitialConfig(); } @@ -8,7 +9,6 @@ async function checkAndConvertJSONToSQL(){ process.stdout.write("Checking if timers.json exists... ") if(fs.existsSync("./data/timers.json")){ process.stdout.write(true + "\n") - await createTimerTables(); await convertTimerJSONToSQL(); fs.renameSync('data/timers.json', 'data/timers.json.old'); console.log("Renamed timers.json to timers.json.old"); @@ -16,57 +16,70 @@ async function checkAndConvertJSONToSQL(){ process.stdout.write(false + "\n") } } -const createTimerTables = require('./server/createDatabaseTables/createTimersTable'); -const createLastfmTable = require('./server/createDatabaseTables/createLastfmTable'); -createLastfmTable(); -checkAndConvertJSONToSQL(); -const { Collection, Client, GatewayIntentBits, Partials } = require('discord.js'); -const client = new Client({ intents: [GatewayIntentBits.Guilds, - GatewayIntentBits.GuildMessages, - GatewayIntentBits.MessageContent, - GatewayIntentBits.GuildMembers, - GatewayIntentBits.GuildPresences - ], partials: [Partials.Channel] }); -const { - globalPrefix, - token, - loginMessage, - loginChannel, - enableLoginMessage, - owners, - presenceType, - presenceText -} = require('./data/config.json'); - -client.settings = new Collection(); -client.commands = new Collection(); -client.serverPrefixes = new Collection(); -client.settings.set("presenceType", presenceType); -client.settings.set("presenceText", presenceText); -const reloadCommands = require("./util/reloadCommands.js"); -const onMessage = require('./server/message'); -const onReady = require('./server/ready'); +function startBot(){ + const { Collection, Client, GatewayIntentBits, Partials } = require('discord.js'); + const client = new Client({ intents: [GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.MessageContent, + GatewayIntentBits.GuildMembers, + GatewayIntentBits.GuildPresences + ], partials: [Partials.Channel] }); + const { + globalPrefix, + token, + loginMessage, + loginChannel, + enableLoginMessage, + owners, + presenceType, + presenceText + } = require('./data/config.json'); -reloadCommands(client) + client.settings = new Collection(); + client.commands = new Collection(); + client.serverPrefixes = new Collection(); -client.once('ready', () => { - onReady(client, enableLoginMessage, loginChannel, loginMessage) + + client.settings.set("presenceType", presenceType); + client.settings.set("presenceText", presenceText); + + const reloadCommands = require("./util/reloadCommands.js"); + const onMessage = require('./server/message'); + const onReady = require('./server/ready'); + + reloadCommands(client) + + client.once('ready', () => { + onReady(client, enableLoginMessage, loginChannel, loginMessage) + }); + + client.once('reconnecting', () => { + console.log('Reconnecting!'); + }); + + client.once('disconnect', () => { + console.log('Disconnect!'); + }); + + client.on('messageCreate', async message => { + onMessage(client, owners, message, globalPrefix); + }); + + + client.login(token); + +} + +async function prepareBot(){ + const createLastfmTable = require('./server/createDatabaseTables/createLastfmTable'); + await createTimersTable(); + await createLastfmTable(); + await checkAndConvertJSONToSQL(); +} + +prepareBot().then( () => { + startBot(); }); - -client.once('reconnecting', () => { - console.log('Reconnecting!'); -}); - -client.once('disconnect', () => { - console.log('Disconnect!'); -}); - -client.on('messageCreate', async message => { - onMessage(client, owners, message, globalPrefix); -}); - - -client.login(token); \ No newline at end of file From 904fa25a6dce06255a8e059f4c57966d90a26a31 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Wed, 6 Nov 2024 09:12:14 +0100 Subject: [PATCH 10/15] Add error if prepareBot fails --- server.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server.js b/server.js index a4105c9..6e2b50d 100644 --- a/server.js +++ b/server.js @@ -82,4 +82,6 @@ async function prepareBot(){ prepareBot().then( () => { startBot(); -}); +}).catch(error => { + console.error("Error preparing the bot:\n", error) +}) From 570a8e49b7e52b38851d3820f4710ae0a7434a0c Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Tue, 17 Dec 2024 10:39:30 +0100 Subject: [PATCH 11/15] Add conversion of custom commands to SQL --- server.js | 74 ++++++++++++++++--- server/convertCustomCommandsJSONToSQL.js | 28 +++++++ .../createCustomCommandsTable.js | 24 ++++++ 3 files changed, 115 insertions(+), 11 deletions(-) create mode 100644 server/convertCustomCommandsJSONToSQL.js create mode 100644 server/createDatabaseTables/createCustomCommandsTable.js diff --git a/server.js b/server.js index 6e2b50d..9f939f9 100644 --- a/server.js +++ b/server.js @@ -2,31 +2,64 @@ const fs = require('fs'); const createInitialConfig = require("./util/createInitialConfig") const convertTimerJSONToSQL = require('./util/timer/convertTimerJSONToSQL.js'); const createTimersTable = require('./server/createDatabaseTables/createTimersTable'); +const createCustomCommandsTable = require('./server/createDatabaseTables/createCustomCommandsTable.js'); +const convertCustomCommandsJSONToSQL = require('./server/convertCustomCommandsJSONToSQL.js'); +const sqlite3 = require('sqlite3').verbose(); if(!fs.existsSync("./data/config.json")) { createInitialConfig(); } + + +const { Collection, Client, GatewayIntentBits, Partials } = require('discord.js'); +const client = new Client({ intents: [GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMessages, + GatewayIntentBits.MessageContent, + GatewayIntentBits.GuildMembers, + GatewayIntentBits.GuildPresences + ], partials: [Partials.Channel] }); + + + + async function checkAndConvertJSONToSQL(){ process.stdout.write("Checking if timers.json exists... ") if(fs.existsSync("./data/timers.json")){ process.stdout.write(true + "\n") await convertTimerJSONToSQL(); + fs.renameSync('data/timers.json', 'data/timers.json.old'); console.log("Renamed timers.json to timers.json.old"); }else{ process.stdout.write(false + "\n") } + + process.stdout.write("Checking if customCommands.json exists... ") + if(fs.existsSync('./data/customCommands.json')){ + process.stdout.write(true + "\n") + await convertCustomCommandsJSONToSQL(); + + fs.renameSync('data/customCommands.json', 'data/customCommands.json.old'); + }else{ + process.stdout.write(false + "\n") + } +} + +async function loadcustomCommands() { + const db = new sqlite3.Database('data/database.db'); + client.customCommands = new Collection(); + db.all("SELECT * FROM customCommands", (error, commands) => { + if(error){ + console.error("Error while loading custom commands:\n",error.message) + }else { + commands.forEach(command => { + client.customCommands.set(command.customName, command.customMessage); + }) + } + }) } - function startBot(){ - const { Collection, Client, GatewayIntentBits, Partials } = require('discord.js'); - const client = new Client({ intents: [GatewayIntentBits.Guilds, - GatewayIntentBits.GuildMessages, - GatewayIntentBits.MessageContent, - GatewayIntentBits.GuildMembers, - GatewayIntentBits.GuildPresences - ], partials: [Partials.Channel] }); const { globalPrefix, token, @@ -75,9 +108,28 @@ function startBot(){ async function prepareBot(){ const createLastfmTable = require('./server/createDatabaseTables/createLastfmTable'); - await createTimersTable(); - await createLastfmTable(); - await checkAndConvertJSONToSQL(); + + + const taskGroups = [ + [ + createTimersTable, + createLastfmTable, + createCustomCommandsTable + ], + [ + checkAndConvertJSONToSQL + ] + ]; + + (async () => { + for (const taskGroup of taskGroups) { + await Promise.all(taskGroup.map(task => task())); + } + loadcustomCommands() + })(); + + + } prepareBot().then( () => { diff --git a/server/convertCustomCommandsJSONToSQL.js b/server/convertCustomCommandsJSONToSQL.js new file mode 100644 index 0000000..101d7e4 --- /dev/null +++ b/server/convertCustomCommandsJSONToSQL.js @@ -0,0 +1,28 @@ +const sqlite3 = require('sqlite3').verbose(); +module.exports = async function () { + const customCommands = require('../data/customCommands.json') + const db = new sqlite3.Database('data/database.db'); + return new Promise((resolve, reject) => { + customCommands.forEach(command => { + const isDeleted = false; + + db.run(`INSERT INTO customCommands ( + customName, + customMessage, + author, + isDeleted + ) VALUES (?, ?, ?, ?)`, [command.customName, command.customMessage, command.author, isDeleted], function (error) { + if (error) { + console.error(`Error while converting customCommands.json to SQL: ${error}`) + reject(error); + } + }) + + + }); + + db.close(); + console.log("Converted customCommands.json to SQL successfully."); + resolve(); + }) +} diff --git a/server/createDatabaseTables/createCustomCommandsTable.js b/server/createDatabaseTables/createCustomCommandsTable.js new file mode 100644 index 0000000..1c89a89 --- /dev/null +++ b/server/createDatabaseTables/createCustomCommandsTable.js @@ -0,0 +1,24 @@ +const sqlite3 = require('sqlite3').verbose(); + +module.exports = async function () { + const db = new sqlite3.Database('data/database.db'); + return new Promise ((resolve, reject)=>{ + db.run( + `CREATE TABLE IF NOT EXISTS customCommands ( + customName TEXT PRIMARY KEY, + customMessage TEXT, + author TEXT, + isDeleted INTEGER)`, + (err) => { + if (err) { + console.error(`Error while creating table 'customCommands': ${err}`); + reject(err); + } else { + console.log("Table 'customCommands' created successfully."); + resolve(); + } + db.close(); + } + ); + }) +} \ No newline at end of file From eae1e9130e4f05ddabb06caa9d256b6634f26dad Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Thu, 19 Dec 2024 18:19:20 +0100 Subject: [PATCH 12/15] Change onmessage to use new custom commands set instead of json file --- server/message.js | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/server/message.js b/server/message.js index 9178afc..1698b6e 100644 --- a/server/message.js +++ b/server/message.js @@ -23,16 +23,10 @@ module.exports = function(client, owners, message, globalPrefix){ const commandName = args.shift().toLowerCase(); const command = client.commands.get(commandName); if (!command){ - const customPath = './data/customCommands.json'; - if(fs.existsSync(customPath)){ - let json = fs.readFileSync(customPath, 'utf8'); - let customCommands = JSON.parse(json) - customCommands.forEach(function (customCommand) { - if (customCommand.customName === commandName) { - let customMessage = customReplaceWithVariables(customCommand.customMessage, message, prefix, globalPrefix) - message.channel.send(customMessage) - } - }); + const command = client.customCommands.get(commandName); + if(command){ + let customMessage = customReplaceWithVariables(command, message, prefix, globalPrefix); + message.channel.send(customMessage); } return; } From 7702f10587d138bbe358538a461e065f108c3f31 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Thu, 19 Dec 2024 18:56:53 +0100 Subject: [PATCH 13/15] Use set for listing all custom commands --- commands/misc/custom.js | 2 +- util/custom_commands/getAllCustomCommands.js | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/commands/misc/custom.js b/commands/misc/custom.js index e39ffb8..39e7ad4 100644 --- a/commands/misc/custom.js +++ b/commands/misc/custom.js @@ -61,7 +61,7 @@ module.exports = { } case "list": { const embed = new EmbedBuilder(); - sendText = getAllCustomCommands(); + sendText = getAllCustomCommands(client); if(sendText !== ""){ embed.setColor(15780145) embed.addFields( diff --git a/util/custom_commands/getAllCustomCommands.js b/util/custom_commands/getAllCustomCommands.js index fba3b28..b40cc6f 100644 --- a/util/custom_commands/getAllCustomCommands.js +++ b/util/custom_commands/getAllCustomCommands.js @@ -1,13 +1,7 @@ -const fs = require('fs'); -module.exports = function(){ - const customPath = './data/customCommands.json'; + + +module.exports = function(client){ let list = ""; - - let json = fs.readFileSync(customPath, 'utf8'); - let customCommands = JSON.parse(json) - customCommands.forEach(function (customCommand) { - list = list + customCommand.customName+"\n"; - }); - + client.customCommands.keys().forEach(commandName => list += `${commandName}\n`) return list; } \ No newline at end of file From 345a03a3b00c1ffcefd8362948fc5d7683419fe2 Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Thu, 19 Dec 2024 19:22:42 +0100 Subject: [PATCH 14/15] Use sqlite database for creating new custom commands --- commands/misc/custom.js | 8 +--- util/custom_commands/addCustomCommand.js | 48 ++++++++++++++---------- 2 files changed, 30 insertions(+), 26 deletions(-) diff --git a/commands/misc/custom.js b/commands/misc/custom.js index 39e7ad4..d31404f 100644 --- a/commands/misc/custom.js +++ b/commands/misc/custom.js @@ -20,11 +20,7 @@ module.exports = { "custom variables - list all variables you can use", "custom count - display the amount of custom commands" ], - execute({message, args, client, prefix, owners}) { - const customPath = 'data/customCommands.json'; - if(!fs.existsSync(customPath)){ - fs.writeFileSync(customPath,"[]") - } + async execute({message, args, client, prefix, owners}) { let sendText; let isEmbed = false; if (args){ @@ -37,7 +33,7 @@ module.exports = { message.channel.send("Message can't be empty"); return; } - sendText = addCustomCommand(customName, customMessage, message.author.id); + sendText = await addCustomCommand(client, customName, customMessage, message.author.id); break; } case "remove": diff --git a/util/custom_commands/addCustomCommand.js b/util/custom_commands/addCustomCommand.js index 3ac6417..a9c1013 100644 --- a/util/custom_commands/addCustomCommand.js +++ b/util/custom_commands/addCustomCommand.js @@ -1,25 +1,33 @@ -const fs = require('fs'); -module.exports = function(customName, customMessage, author){ - let sendText; - const customPath = './data/customCommands.json'; - - let json = fs.readFileSync(customPath, 'utf8'); - let customCommands = JSON.parse(json) +const sqlite3 = require('sqlite3').verbose(); +module.exports = async function(client, customName, customMessage, author){ + + let sendText = ""; + let isExists = client.customCommands.get(customName); - let isExists = false; - customCommands.forEach(function (customCommand) { - if (customCommand.customName === customName) { - sendText = "This custom command already exists"; - isExists = true; - } - }); if (!isExists) { - let newCustomCommand = { - "customName": customName, "customMessage": customMessage, "author": author - } - customCommands.push(newCustomCommand) - sendText = `New custom command with the name "${customName}" added` + const db = new sqlite3.Database("data/database.db"); + sendText = await new Promise((resolve, reject)=>{ + + db.run(`INSERT INTO customCommands ( + customName, + customMessage, + author, + isDeleted + ) VALUES (?, ?, ?, ?)`, [customName, customMessage, author, false], + + function(error){ + if(error){ + console.error(error) + let sendText = "Error while inserting new custom command."; + reject(sendText); + }else{ + client.customCommands.set(customName, customMessage) + let sendText = `New custom command with the name "${customName}" added` + resolve(sendText) + } + }) + }) + db.close(); } - fs.writeFileSync(customPath, JSON.stringify(customCommands, null, 4)) return sendText; } \ No newline at end of file From 0c45055e0f6568913653451d9e3030023f15d33a Mon Sep 17 00:00:00 2001 From: SileNce5k Date: Thu, 19 Dec 2024 19:52:02 +0100 Subject: [PATCH 15/15] Use SQL on owner custom command subcommand --- commands/misc/custom.js | 2 +- .../getOwnerOfCustomCommand.js | 32 +++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/commands/misc/custom.js b/commands/misc/custom.js index d31404f..71885df 100644 --- a/commands/misc/custom.js +++ b/commands/misc/custom.js @@ -42,7 +42,7 @@ module.exports = { break; } case "owner":{ - let author = getOwnerOfCustomCommand(customName); + let author = await getOwnerOfCustomCommand(customName); let user; if(!author) sendText = `${customName} does not exist` diff --git a/util/custom_commands/getOwnerOfCustomCommand.js b/util/custom_commands/getOwnerOfCustomCommand.js index f0106c0..1617415 100644 --- a/util/custom_commands/getOwnerOfCustomCommand.js +++ b/util/custom_commands/getOwnerOfCustomCommand.js @@ -1,10 +1,24 @@ -const fs = require('fs'); -module.exports = function(customName){ - const customPath = './data/customCommands.json'; - let json = fs.readFileSync(customPath, 'utf8'); - let customCommands = JSON.parse(json) - let author = customCommands.filter(customCommands => customCommands.customName === customName); - if(author.length === 0) return false; - return author[0].author; - + +const sqlite3 = require('sqlite3').verbose(); +module.exports = async function(customName){ + const db = new sqlite3.Database("data/database.db"); + + let author = await new Promise((resolve, reject)=>{ + db.get("SELECT * FROM customCommands WHERE customName = ? AND isDeleted = 0", [customName], + function(error, command){ + if(error){ + console.error(error) + let author = "Error when getting the owner of this custom command. Check console."; + reject(author) + }else { + let author; + if(command){ + author = command.author; + } + resolve(author) + } + }) + }) + + return author; } \ No newline at end of file