From 2a8e253f4f32c378f5b5b2fcb252edd48ac2edf5 Mon Sep 17 00:00:00 2001 From: Taken Date: Sat, 24 Aug 2024 22:58:15 +0200 Subject: [PATCH 1/5] Formatting Signed-off-by: Taken --- eslint.config.mjs | 146 +++++++++++++++++++++++++--------------------- package.json | 136 +++++++++++++++++++++--------------------- 2 files changed, 146 insertions(+), 136 deletions(-) diff --git a/eslint.config.mjs b/eslint.config.mjs index 469ca94..9287416 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -16,77 +16,87 @@ const compat = new FlatCompat({ allConfig: js.configs.all }) -export default [{ - ignores: ["**/node_modules", "**/dist"], -}, ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"), { - plugins: { - "@typescript-eslint": typescriptEslint, +export default [ + { + ignores: ["**/node_modules", "**/dist"] }, - - languageOptions: { - globals: { - ...globals.node, - ...globals.browser, + ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended"), + { + plugins: { + "@typescript-eslint": typescriptEslint, }, - parser: tsParser, - ecmaVersion: "latest", - sourceType: "module", - }, + languageOptions: { + globals: { + ...globals.node, + ...globals.browser, + }, - rules: { - indent: ["error", 4, { - SwitchCase: 1, - }], - - "linebreak-style": ["error", "unix"], - quotes: ["warn", "double"], - semi: ["error", "never"], - "no-unused-vars": "off", - "prefer-const": "warn", - "no-var": "error", - - "no-multiple-empty-lines": ["error", { - max: 2, - maxEOF: 1, - maxBOF: 0, - }], - - "no-lonely-if": "error", - "no-empty-function": "error", - "no-inline-comments": "error", - "no-trailing-spaces": ["error"], - - "arrow-spacing": ["warn", { - before: true, - after: true, - }], - - "space-before-function-paren": ["error", { - anonymous: "never", - named: "never", - asyncArrow: "always", - }], - - "comma-spacing": "error", - "@typescript-eslint/no-var-requires": "off", - "@typescript-eslint/no-explicit-any": "off", - - "@typescript-eslint/no-unused-vars": ["warn", { - vars: "all", - args: "after-used", - ignoreRestSiblings: false, - }], - "@typescript-eslint/no-empty-object-type": "off", - "@typescript-eslint/no-require-imports": "off", - }, -}, { - languageOptions: { - globals: { - ...globals.node, + parser: tsParser, + ecmaVersion: "latest", + sourceType: "module", }, - ecmaVersion: 5, - sourceType: "commonjs", - }, -}] \ No newline at end of file + rules: { + indent: ["error", 4, { + SwitchCase: 1, + }], + + "linebreak-style": ["error", "unix"], + quotes: ["warn", "double"], + semi: ["error", "never"], + "no-unused-vars": "off", + "prefer-const": "warn", + "no-var": "error", + + "no-multiple-empty-lines": ["error", { + max: 2, + maxEOF: 1, + maxBOF: 0, + }], + + "no-lonely-if": "error", + "no-empty-function": "error", + "no-inline-comments": "error", + "no-trailing-spaces": ["error"], + + "arrow-spacing": ["warn", { + before: true, + after: true, + }], + + "space-before-function-paren": ["error", { + anonymous: "never", + named: "never", + asyncArrow: "always", + }], + + "comma-spacing": "error", + "@typescript-eslint/no-var-requires": "off", + "@typescript-eslint/no-explicit-any": "off", + + "@typescript-eslint/no-unused-vars": ["warn", { + vars: "all", + args: "after-used", + ignoreRestSiblings: false, + }], + "@typescript-eslint/no-empty-object-type": "off", + "@typescript-eslint/no-require-imports": "off", + "@typescript-eslint/ban-ts-comment": ["error", { + "ts-expect-error": "allow-with-description", + "ts-ignore": "allow-with-description", + "ts-nocheck": "allow-with-description", + "ts-check": "allow-with-description", + }], + }, + }, { + languageOptions: { + globals: { + ...globals.node, + }, + + ecmaVersion: 5, + sourceType: "commonjs", + }, + } +] diff --git a/package.json b/package.json index adb1a36..fb37f9a 100644 --- a/package.json +++ b/package.json @@ -1,70 +1,70 @@ { - "name": "illegitimate-bot", - "displayName": "Illegitimate Bot", - "version": "1.0.0", - "description": "", - "main": "src/index.ts", - "type": "module", - "repository": { - "type": "git", - "url": "https://gitlab.com/illegitimate/illegitimate-bot" - }, - "homepage": "https://gitlab.com/illegitimate/illegitimate-bot", - "scripts": { - "start": "node dist/index.js", - "build": "swc src -d dist --strip-leading-paths", - "watch": "swc src -d dist --strip-leading-paths --watch", - "dev": "nodemon --config nodemon-swc.json", - "dev:conc": "conc --names \"SWC,BOT\" --prefix-colors \"blue, magenta\" \"yarn watch\" \"yarn dev:js\"", - "dev:ts": "nodemon --config nodemon.json src/index.ts", - "dev:js": "nodemon --config nodemon-js.json dist/index.js", - "check": "tsc --noEmit", - "lint": "eslint", - "lint:fix": "eslint --fix", - "push:prod": "cross-env NODE_PATH=src/ \"ts-node scripts/deploy-commands.ts\"", - "push:dev": "cross-env NODE_PATH=src/ \"ts-node scripts/dev-deploy.ts\"", - "delete:dev": "ts-node scripts/delete-commands.ts" - }, - "author": "Taken", - "license": "GPL-3.0-only", - "dependencies": { - "@discord-player/extractor": "^4.5.1", - "@evan/opus": "^1.0.3", - "anilist": "^0.12.4", - "axios": "^1.7.5", - "chalk": "^5.3.0", - "cron": "^3.1.7", - "discord-player": "^6.7.1", - "discord-player-youtubei": "^1.2.6", - "discord.js": "^14.15.3", - "dotenv": "^16.4.5", - "ioredis": "^5.4.1", - "mongoose": "^8.5.3", - "ms": "^2.1.3", - "pg": "^8.12.0", - "pg-hstore": "^2.3.4", - "pretty-ms": "^9.1.0", - "sequelize": "^6.37.3", - "youtube-ext": "^1.1.25" - }, - "devDependencies": { - "@eslint/eslintrc": "^3.1.0", - "@eslint/js": "^9.9.0", - "@swc/cli": "^0.4.0", - "@swc/core": "^1.7.14", - "@types/ms": "^0.7.34", - "@types/node": "^22.5.0", - "@types/pg": "^8", - "@typescript-eslint/eslint-plugin": "^8.2.0", - "@typescript-eslint/parser": "^8.2.0", - "chokidar": "^3.6.0", - "concurrently": "^8.2.2", - "cross-env": "^7.0.3", - "eslint": "^9.9.0", - "globals": "^15.9.0", - "sqlite3": "^5.1.7", - "ts-node": "^10.9.2", - "typescript": "^5.5.4" - }, - "packageManager": "yarn@4.4.0" + "name": "illegitimate-bot", + "displayName": "Illegitimate Bot", + "version": "1.0.0", + "description": "", + "main": "src/index.ts", + "type": "module", + "repository": { + "type": "git", + "url": "https://gitlab.com/illegitimate/illegitimate-bot" + }, + "homepage": "https://gitlab.com/illegitimate/illegitimate-bot", + "scripts": { + "start": "node dist/index.js", + "build": "swc src -d dist --strip-leading-paths", + "watch": "swc src -d dist --strip-leading-paths --watch", + "dev": "nodemon --config nodemon-swc.json", + "dev:conc": "conc --names \"SWC,BOT\" --prefix-colors \"blue, magenta\" \"yarn watch\" \"yarn dev:js\"", + "dev:ts": "nodemon --config nodemon.json src/index.ts", + "dev:js": "nodemon --config nodemon-js.json dist/index.js", + "check": "tsc --noEmit", + "lint": "eslint", + "lint:fix": "eslint --fix", + "push:prod": "cross-env NODE_PATH=src/ \"ts-node scripts/deploy-commands.ts\"", + "push:dev": "cross-env NODE_PATH=src/ \"ts-node scripts/dev-deploy.ts\"", + "delete:dev": "ts-node scripts/delete-commands.ts" + }, + "author": "Taken", + "license": "GPL-3.0-only", + "dependencies": { + "@discord-player/extractor": "^4.5.1", + "@evan/opus": "^1.0.3", + "anilist": "^0.12.4", + "axios": "^1.7.5", + "chalk": "^5.3.0", + "cron": "^3.1.7", + "discord-player": "^6.7.1", + "discord-player-youtubei": "^1.2.6", + "discord.js": "^14.15.3", + "dotenv": "^16.4.5", + "ioredis": "^5.4.1", + "mongoose": "^8.5.3", + "ms": "^2.1.3", + "pg": "^8.12.0", + "pg-hstore": "^2.3.4", + "pretty-ms": "^9.1.0", + "sequelize": "^6.37.3", + "youtube-ext": "^1.1.25" + }, + "devDependencies": { + "@eslint/eslintrc": "^3.1.0", + "@eslint/js": "^9.9.0", + "@swc/cli": "^0.4.0", + "@swc/core": "^1.7.14", + "@types/ms": "^0.7.34", + "@types/node": "^22.5.0", + "@types/pg": "^8", + "@typescript-eslint/eslint-plugin": "^8.2.0", + "@typescript-eslint/parser": "^8.2.0", + "chokidar": "^3.6.0", + "concurrently": "^8.2.2", + "cross-env": "^7.0.3", + "eslint": "^9.9.0", + "globals": "^15.9.0", + "sqlite3": "^5.1.7", + "ts-node": "^10.9.2", + "typescript": "^5.5.4" + }, + "packageManager": "yarn@4.4.0" } From 8b8c50551f223c0f3d23eb40023dc4bd6da5634c Mon Sep 17 00:00:00 2001 From: Taken Date: Sat, 24 Aug 2024 22:59:02 +0200 Subject: [PATCH 2/5] Remove extra declaration --- src/utils/Events/autocomplete.ts | 3 +-- src/utils/Events/button.ts | 3 +-- src/utils/Events/command.ts | 3 +-- src/utils/Events/contextmenu.ts | 3 +-- src/utils/Events/cron.ts | 3 +-- src/utils/Events/events.ts | 3 +-- src/utils/Events/modal.ts | 3 +-- 7 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/utils/Events/autocomplete.ts b/src/utils/Events/autocomplete.ts index b1a01d4..db5d5e4 100644 --- a/src/utils/Events/autocomplete.ts +++ b/src/utils/Events/autocomplete.ts @@ -15,8 +15,7 @@ export default async function loadAutocompleteEvents(client: Client, ft: FileTyp for (const file of autocompleteFiles) { const filePath = path.join(autocompletePath, file) - const { default: autocompleteImport } = await import("file://" + filePath) - const autocomplete: IAutocomplete = autocompleteImport + const { default: autocomplete } = await import("file://" + filePath) as { default: IAutocomplete } if ("name" in autocomplete && "execute" in autocomplete) { client.autocomplete.set(autocomplete.name, autocomplete) diff --git a/src/utils/Events/button.ts b/src/utils/Events/button.ts index c8fe38b..0959a58 100644 --- a/src/utils/Events/button.ts +++ b/src/utils/Events/button.ts @@ -15,8 +15,7 @@ export default async function loadButtonEvents(client: Client, ft: FileType) { for (const file of btnFiles) { const filePath = path.join(btnPath, file) - const { default: btnImport } = await import("file://" + filePath) - const btn: IButton = btnImport + const { default: btn } = await import("file://" + filePath) as { default: IButton } if ("name" in btn && "execute" in btn) { client.buttons.set(btn.name, btn) diff --git a/src/utils/Events/command.ts b/src/utils/Events/command.ts index bd4599e..53b1b10 100644 --- a/src/utils/Events/command.ts +++ b/src/utils/Events/command.ts @@ -15,8 +15,7 @@ export default async function loadSlashCommandsEvents(client: Client, ft: FileTy for (const file of cmdFiles) { const filePath = path.join(cmdPath, file) - const { default: cmdImport } = await import("file://" + filePath) - const cmd: ICommand = cmdImport + const { default: cmd } = await import("file://" + filePath) as { default: ICommand } if ("data" in cmd && "execute" in cmd) { client.commands.set(cmd.data.name, cmd) diff --git a/src/utils/Events/contextmenu.ts b/src/utils/Events/contextmenu.ts index bc03fce..cb63aa8 100644 --- a/src/utils/Events/contextmenu.ts +++ b/src/utils/Events/contextmenu.ts @@ -15,8 +15,7 @@ export default async function loadContextMenuEvents(client: Client, ft: FileType for (const file of contextMenuFiles) { const filePath = path.join(contextMenuPath, file) - const { default: cmdImport } = await import("file://" + filePath) - const cmd: IContextMenu = cmdImport + const { default: cmd } = await import("file://" + filePath) as { default: IContextMenu } if ("data" in cmd && "execute" in cmd) { client.contextmenus.set(cmd.data.name, cmd) diff --git a/src/utils/Events/cron.ts b/src/utils/Events/cron.ts index 0fbe9d9..b7810b9 100644 --- a/src/utils/Events/cron.ts +++ b/src/utils/Events/cron.ts @@ -10,8 +10,7 @@ export default async function loadCronEvents() { for (const file of cronFiles) { const filePath = path.join(cronPath, file) - const { default: cronImport } = await import("file://" + filePath) - const cron: ICron = cronImport + const { default: cron } = await import("file://" + filePath) as { default: ICron } const time = cron.time.seconds + " " + diff --git a/src/utils/Events/events.ts b/src/utils/Events/events.ts index 34c7536..3642843 100644 --- a/src/utils/Events/events.ts +++ b/src/utils/Events/events.ts @@ -11,8 +11,7 @@ export default async function loadEvents(client: Client) { const eventFiles = fs.readdirSync(path.join(serverDir, eventDir)) for (const eventFile of eventFiles) { const eventPath = path.join(serverDir, eventDir, eventFile) - const { default: eventImport } = await import("file://" + eventPath) - const event: IEvent = eventImport + const { default: event } = await import("file://" + eventPath) as { default: IEvent } if (!event.disabled) { client.on(event.event, event.execute) } diff --git a/src/utils/Events/modal.ts b/src/utils/Events/modal.ts index 973b887..f6e4fe1 100644 --- a/src/utils/Events/modal.ts +++ b/src/utils/Events/modal.ts @@ -15,8 +15,7 @@ export default async function loadModalEvents(client: Client, ft: FileType) { for (const file of modalFiles) { const filePath = path.join(modalPath, file) - const { default: modalImport } = await import("file://" + filePath) - const modal: IModal = modalImport + const { default: modal } = await import("file://" + filePath) as { default: IModal } if ("name" in modal && "execute" in modal) { client.modals.set(modal.name, modal) From b29d6e75a88776904c7212163d61eac5f82b6bae Mon Sep 17 00:00:00 2001 From: Taken Date: Sat, 24 Aug 2024 22:59:49 +0200 Subject: [PATCH 3/5] Forgot to uncomment this --- src/utils/Illegitimate.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils/Illegitimate.ts b/src/utils/Illegitimate.ts index af8c2ca..8c1a6fc 100644 --- a/src/utils/Illegitimate.ts +++ b/src/utils/Illegitimate.ts @@ -44,11 +44,11 @@ class Illegitimate { redis.on("ready", () => { console.log(color("Connected to Redis", "green")) }) - // if (process.env.NODE_ENV === "dev") { - // sequelize.sync().then(() => { - // console.log(color("Synced the db [dev]", "green")) - // }) - // } + if (process.env.NODE_ENV === "dev") { + sequelize.sync().then(() => { + console.log(color("Synced the db [dev]", "green")) + }) + } // connect(env.prod.mongoURI!, {}).then(() => { // console.log(color("Connected to MongoDB", "green")) // }) From 37a95bda70fdd1291ad5b3612700c3c505918406 Mon Sep 17 00:00:00 2001 From: Taken Date: Sat, 24 Aug 2024 22:59:59 +0200 Subject: [PATCH 4/5] Added schema to tsconfig --- tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 255e0d8..3acb70c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,4 +1,5 @@ { + "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { "target": "ES2022", "module": "ES2022", @@ -24,4 +25,4 @@ }, "include": ["src"], "exclude": ["node_modules"] -} \ No newline at end of file +} From 17896844a5127b2a1bc79eb90e89a7ac65d36b47 Mon Sep 17 00:00:00 2001 From: Taken Date: Sat, 24 Aug 2024 23:04:22 +0200 Subject: [PATCH 5/5] Added schema entries for all json files --- nodemon-js.json | 1 + nodemon-swc.json | 3 ++- nodemon.json | 1 + package.json | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/nodemon-js.json b/nodemon-js.json index 7a3460f..ecc687b 100644 --- a/nodemon-js.json +++ b/nodemon-js.json @@ -1,4 +1,5 @@ { + "$schema": "https://json.schemastore.org/nodemon.json", "restartable": "rs", "ignore": [ ".git", diff --git a/nodemon-swc.json b/nodemon-swc.json index 8e60f8c..5587b2f 100644 --- a/nodemon-swc.json +++ b/nodemon-swc.json @@ -1,4 +1,5 @@ { + "$schema": "https://json.schemastore.org/nodemon.json", "ignore": [ ".git", "node_modules", @@ -9,4 +10,4 @@ }, "ext": "ts", "exec": "yarn build && yarn start" -} \ No newline at end of file +} diff --git a/nodemon.json b/nodemon.json index 754a245..7b077ce 100644 --- a/nodemon.json +++ b/nodemon.json @@ -1,4 +1,5 @@ { + "$schema": "https://json.schemastore.org/nodemon.json", "restartable": "rs", "ignore": [ ".git", diff --git a/package.json b/package.json index fb37f9a..70a12ef 100644 --- a/package.json +++ b/package.json @@ -1,4 +1,5 @@ { + "$schema": "https://json.schemastore.org/package.json", "name": "illegitimate-bot", "displayName": "Illegitimate Bot", "version": "1.0.0",