diff --git a/commands/general/exec.js b/commands/general/exec.js index 9b243b7c..b70f934e 100644 --- a/commands/general/exec.js +++ b/commands/general/exec.js @@ -2,10 +2,10 @@ import { Buffer } from "node:buffer"; import { exec as baseExec } from "node:child_process"; import process from "node:process"; import { promisify } from "node:util"; -import { clean } from "#utils/misc.js"; -const exec = promisify(baseExec); import { Constants } from "oceanic.js"; import Command from "#cmd-classes/command.js"; +import { clean } from "#utils/misc.js"; +const exec = promisify(baseExec); class ExecCommand extends Command { async run() { diff --git a/commands/general/stats.js b/commands/general/stats.js index 39cb8dc2..4d69968b 100644 --- a/commands/general/stats.js +++ b/commands/general/stats.js @@ -2,10 +2,11 @@ import os from "node:os"; import process from "node:process"; import { VERSION } from "oceanic.js"; import Command from "#cmd-classes/command.js"; +import detectRuntime from "#utils/detectRuntime.js"; +import { getServers } from "#utils/misc.js"; import packageJson from "../../package.json" with { type: "json" }; + const pm2 = process.env.PM2_USAGE ? (await import("pm2")).default : null; -import { getServers } from "#utils/misc.js"; -import detectRuntime from "#utils/detectRuntime.js"; class StatsCommand extends Command { async run() { diff --git a/commands/image-editing/fade.js b/commands/image-editing/fade.js index 50a5bb89..7350e6af 100644 --- a/commands/image-editing/fade.js +++ b/commands/image-editing/fade.js @@ -1,5 +1,5 @@ -import ImageCommand from "#cmd-classes/imageCommand.js"; import { Constants } from "oceanic.js"; +import ImageCommand from "#cmd-classes/imageCommand.js"; class FadeCommand extends ImageCommand { paramsFunc() { diff --git a/commands/image-editing/hue.js b/commands/image-editing/hue.js index 3119676e..3d0d0ac5 100644 --- a/commands/image-editing/hue.js +++ b/commands/image-editing/hue.js @@ -1,5 +1,5 @@ -import ImageCommand from "#cmd-classes/imageCommand.js"; import { Constants } from "oceanic.js"; +import ImageCommand from "#cmd-classes/imageCommand.js"; class HueCommand extends ImageCommand { paramsFunc() { diff --git a/commands/image-editing/wide.js b/commands/image-editing/wide.js index 2eaf7188..6a27114a 100644 --- a/commands/image-editing/wide.js +++ b/commands/image-editing/wide.js @@ -1,5 +1,5 @@ -import ImageCommand from "#cmd-classes/imageCommand.js"; import { Constants } from "oceanic.js"; +import ImageCommand from "#cmd-classes/imageCommand.js"; class WideCommand extends ImageCommand { paramsFunc() { diff --git a/commands/music/music/host.js b/commands/music/music/host.js index 4684b8eb..0f779f41 100644 --- a/commands/music/music/host.js +++ b/commands/music/music/host.js @@ -2,8 +2,8 @@ import process from "node:process"; import { Constants, User } from "oceanic.js"; import MusicCommand from "#cmd-classes/musicCommand.js"; import logger from "#utils/logger.js"; -import { players } from "#utils/soundplayer.js"; import { safeBigInt } from "#utils/misc.js"; +import { players } from "#utils/soundplayer.js"; class MusicHostCommand extends MusicCommand { async run() { diff --git a/commands/tags/tags/add.js b/commands/tags/tags/add.js index 8d9991ee..289173ae 100644 --- a/commands/tags/tags/add.js +++ b/commands/tags/tags/add.js @@ -1,5 +1,5 @@ -import Command from "#cmd-classes/command.js"; import { Constants } from "oceanic.js"; +import Command from "#cmd-classes/command.js"; const blacklist = ["create", "add", "edit", "remove", "delete", "list", "random", "own", "owner"]; diff --git a/commands/tags/tags/delete.js b/commands/tags/tags/delete.js index b4597446..68c1b3df 100644 --- a/commands/tags/tags/delete.js +++ b/commands/tags/tags/delete.js @@ -1,5 +1,5 @@ -import Command from "#cmd-classes/command.js"; import { Constants } from "oceanic.js"; +import Command from "#cmd-classes/command.js"; class TagsDeleteCommand extends Command { async run() { diff --git a/commands/tags/tags/edit.js b/commands/tags/tags/edit.js index f8a4cc22..75e73242 100644 --- a/commands/tags/tags/edit.js +++ b/commands/tags/tags/edit.js @@ -1,5 +1,5 @@ -import Command from "#cmd-classes/command.js"; import { Constants } from "oceanic.js"; +import Command from "#cmd-classes/command.js"; class TagsEditCommand extends Command { async run() { diff --git a/commands/tags/tags/get.js b/commands/tags/tags/get.js index 5e356399..35758acc 100644 --- a/commands/tags/tags/get.js +++ b/commands/tags/tags/get.js @@ -1,5 +1,5 @@ -import Command from "#cmd-classes/command.js"; import { Constants } from "oceanic.js"; +import Command from "#cmd-classes/command.js"; class TagsGetCommand extends Command { async run() { diff --git a/commands/tags/tags/owner.js b/commands/tags/tags/owner.js index d917164d..76c11466 100644 --- a/commands/tags/tags/owner.js +++ b/commands/tags/tags/owner.js @@ -1,5 +1,5 @@ -import Command from "#cmd-classes/command.js"; import { Constants } from "oceanic.js"; +import Command from "#cmd-classes/command.js"; class TagsOwnerCommand extends Command { async run() { diff --git a/commands/tags/tags/role.js b/commands/tags/tags/role.js index d9cb463a..6a86a1a0 100644 --- a/commands/tags/tags/role.js +++ b/commands/tags/tags/role.js @@ -1,7 +1,7 @@ import { Constants } from "oceanic.js"; -import TagsGetCommand from "./get.js"; import paginator from "#pagination"; import { mentionToObject } from "#utils/mentions.js"; +import TagsGetCommand from "./get.js"; class TagsRoleCommand extends TagsGetCommand { async run() { diff --git a/eslint.config.js b/eslint.config.js index 6f367e4d..558de201 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -1,12 +1,15 @@ // @ts-check -import eslint from "@eslint/js"; -import { includeIgnoreFile } from "@eslint/compat"; import path from "node:path"; import { fileURLToPath } from "node:url"; -import tseslint from "typescript-eslint"; + +import { includeIgnoreFile } from "@eslint/compat"; +import eslint from "@eslint/js"; +import * as tsResolver from "eslint-import-resolver-typescript"; +import { importX } from "eslint-plugin-import-x"; import prettier from "eslint-plugin-prettier/recommended"; import globals from "globals"; +import tseslint from "typescript-eslint"; const __filename = fileURLToPath(import.meta.url); const __dirname = path.dirname(__filename); @@ -17,7 +20,18 @@ export default tseslint.config( prettier, eslint.configs.recommended, tseslint.configs.recommended, + importX.flatConfigs.recommended, + importX.flatConfigs.typescript, { + settings: { + "import-x/resolver": { + name: "tsResolver", + options: { + bun: true, + }, + resolver: tsResolver, + }, + }, languageOptions: { globals: { ...globals.node, @@ -26,6 +40,19 @@ export default tseslint.config( sourceType: "module", }, rules: { + "import-x/no-named-as-default-member": "off", + "import-x/order": [ + "error", + { + alphabetize: { + order: "asc", + }, + + "newlines-between": "ignore", + + groups: ["builtin", "external", "internal", "parent", ["index", "sibling"], "object"], + }, + ], "@typescript-eslint/no-unused-vars": [ "error", { diff --git a/package.json b/package.json index 0d5ae98b..0e2bfe00 100644 --- a/package.json +++ b/package.json @@ -72,6 +72,8 @@ "cmake-js": "^7.3.1", "eslint": "^9.32.0", "eslint-config-prettier": "^10.1.8", + "eslint-import-resolver-typescript": "^4.4.4", + "eslint-plugin-import-x": "^4.16.1", "eslint-plugin-prettier": "^5.5.3", "globals": "^16.3.0", "prettier": "^3.6.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 18a58c35..04e4f8fd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -89,6 +89,12 @@ importers: eslint-config-prettier: specifier: ^10.1.8 version: 10.1.8(eslint@9.32.0) + eslint-import-resolver-typescript: + specifier: ^4.4.4 + version: 4.4.4(eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.39.0(eslint@9.32.0)(typescript@5.9.2))(eslint@9.32.0))(eslint@9.32.0) + eslint-plugin-import-x: + specifier: ^4.16.1 + version: 4.16.1(@typescript-eslint/utils@8.39.0(eslint@9.32.0)(typescript@5.9.2))(eslint@9.32.0) eslint-plugin-prettier: specifier: ^5.5.3 version: 5.5.3(eslint-config-prettier@10.1.8(eslint@9.32.0))(eslint@9.32.0)(prettier@3.6.2) @@ -127,6 +133,15 @@ packages: '@dabh/diagnostics@2.0.3': resolution: {integrity: sha512-hrlQOIi7hAfzsMqlGSFyVucrx38O+j6wiGOf//H2ecvIEqYN4ADBSS2iLMh5UFyDunCNniUIPk/q3riFv45xRA==} + '@emnapi/core@1.4.5': + resolution: {integrity: sha512-XsLw1dEOpkSX/WucdqUhPWP7hDxSvZiY+fsUC14h+FtQ2Ifni4znbBt8punRX+Uj2JG/uDb8nEHVKvrVlvdZ5Q==} + + '@emnapi/runtime@1.4.5': + resolution: {integrity: sha512-++LApOtY0pEEz1zrd9vy1/zXVaVJJ/EbAF3u0fXIzPJEDtnITsBGbbK0EkM72amhl/R5b+5xx0Y/QhcVOpuulg==} + + '@emnapi/wasi-threads@1.0.4': + resolution: {integrity: sha512-PJR+bOmMOPH8AtcTGAyYNiuJ3/Fcoj2XN/gBEWzDIKh254XO+mM9XoXHk5GNEhodxeMznbg7BlRojVbKN+gC6g==} + '@eslint-community/eslint-utils@4.7.0': resolution: {integrity: sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -224,6 +239,9 @@ packages: '@jsr/std__path@1.1.1': resolution: {integrity: sha512-+x5LgcNUSpMzOZIRmFSjqrMTCxHlgXjWzK8ZFr7lwgHfWZxoVXeis3MFQlkR5mN5uQ61Y1P30Li1PU0yx9uluA==, tarball: https://npm.jsr.io/~/11/@jsr/std__path/1.1.1.tgz} + '@napi-rs/wasm-runtime@0.2.12': + resolution: {integrity: sha512-ZVWUcfwY4E/yPitQJl481FjFo3K22D6qF0DuFH6Y/nbnE11GY5uguDxZMGXPQ8WQ0128MXQD7TnfHyK4oWoIJQ==} + '@nodelib/fs.scandir@2.1.5': resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -500,6 +518,9 @@ packages: '@tootallnate/quickjs-emscripten@0.23.0': resolution: {integrity: sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA==} + '@tybys/wasm-util@0.10.0': + resolution: {integrity: sha512-VyyPYFlOMNylG45GoAe0xDoLwWuowvf92F9kySqzYh8vmYm7D2u4iUJKa1tOUpS70Ku13ASrOkS4ScXFsTaCNQ==} + '@types/better-sqlite3@7.6.13': resolution: {integrity: sha512-NMv9ASNARoKksWtsq/SHakpYAYnhBrQgGD8zkLYk/jaK8jUGn08CfEdTRgYhMypUQAfzSP8W6gNLe0q19/t4VA==} @@ -604,6 +625,101 @@ packages: resolution: {integrity: sha512-ldgiJ+VAhQCfIjeOgu8Kj5nSxds0ktPOSO9p4+0VDH2R2pLvQraaM5Oen2d7NxzMCm+Sn/vJT+mv2H5u6b/3fA==} engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + '@unrs/resolver-binding-android-arm-eabi@1.11.1': + resolution: {integrity: sha512-ppLRUgHVaGRWUx0R0Ut06Mjo9gBaBkg3v/8AxusGLhsIotbBLuRk51rAzqLC8gq6NyyAojEXglNjzf6R948DNw==} + cpu: [arm] + os: [android] + + '@unrs/resolver-binding-android-arm64@1.11.1': + resolution: {integrity: sha512-lCxkVtb4wp1v+EoN+HjIG9cIIzPkX5OtM03pQYkG+U5O/wL53LC4QbIeazgiKqluGeVEeBlZahHalCaBvU1a2g==} + cpu: [arm64] + os: [android] + + '@unrs/resolver-binding-darwin-arm64@1.11.1': + resolution: {integrity: sha512-gPVA1UjRu1Y/IsB/dQEsp2V1pm44Of6+LWvbLc9SDk1c2KhhDRDBUkQCYVWe6f26uJb3fOK8saWMgtX8IrMk3g==} + cpu: [arm64] + os: [darwin] + + '@unrs/resolver-binding-darwin-x64@1.11.1': + resolution: {integrity: sha512-cFzP7rWKd3lZaCsDze07QX1SC24lO8mPty9vdP+YVa3MGdVgPmFc59317b2ioXtgCMKGiCLxJ4HQs62oz6GfRQ==} + cpu: [x64] + os: [darwin] + + '@unrs/resolver-binding-freebsd-x64@1.11.1': + resolution: {integrity: sha512-fqtGgak3zX4DCB6PFpsH5+Kmt/8CIi4Bry4rb1ho6Av2QHTREM+47y282Uqiu3ZRF5IQioJQ5qWRV6jduA+iGw==} + cpu: [x64] + os: [freebsd] + + '@unrs/resolver-binding-linux-arm-gnueabihf@1.11.1': + resolution: {integrity: sha512-u92mvlcYtp9MRKmP+ZvMmtPN34+/3lMHlyMj7wXJDeXxuM0Vgzz0+PPJNsro1m3IZPYChIkn944wW8TYgGKFHw==} + cpu: [arm] + os: [linux] + + '@unrs/resolver-binding-linux-arm-musleabihf@1.11.1': + resolution: {integrity: sha512-cINaoY2z7LVCrfHkIcmvj7osTOtm6VVT16b5oQdS4beibX2SYBwgYLmqhBjA1t51CarSaBuX5YNsWLjsqfW5Cw==} + cpu: [arm] + os: [linux] + + '@unrs/resolver-binding-linux-arm64-gnu@1.11.1': + resolution: {integrity: sha512-34gw7PjDGB9JgePJEmhEqBhWvCiiWCuXsL9hYphDF7crW7UgI05gyBAi6MF58uGcMOiOqSJ2ybEeCvHcq0BCmQ==} + cpu: [arm64] + os: [linux] + + '@unrs/resolver-binding-linux-arm64-musl@1.11.1': + resolution: {integrity: sha512-RyMIx6Uf53hhOtJDIamSbTskA99sPHS96wxVE/bJtePJJtpdKGXO1wY90oRdXuYOGOTuqjT8ACccMc4K6QmT3w==} + cpu: [arm64] + os: [linux] + + '@unrs/resolver-binding-linux-ppc64-gnu@1.11.1': + resolution: {integrity: sha512-D8Vae74A4/a+mZH0FbOkFJL9DSK2R6TFPC9M+jCWYia/q2einCubX10pecpDiTmkJVUH+y8K3BZClycD8nCShA==} + cpu: [ppc64] + os: [linux] + + '@unrs/resolver-binding-linux-riscv64-gnu@1.11.1': + resolution: {integrity: sha512-frxL4OrzOWVVsOc96+V3aqTIQl1O2TjgExV4EKgRY09AJ9leZpEg8Ak9phadbuX0BA4k8U5qtvMSQQGGmaJqcQ==} + cpu: [riscv64] + os: [linux] + + '@unrs/resolver-binding-linux-riscv64-musl@1.11.1': + resolution: {integrity: sha512-mJ5vuDaIZ+l/acv01sHoXfpnyrNKOk/3aDoEdLO/Xtn9HuZlDD6jKxHlkN8ZhWyLJsRBxfv9GYM2utQ1SChKew==} + cpu: [riscv64] + os: [linux] + + '@unrs/resolver-binding-linux-s390x-gnu@1.11.1': + resolution: {integrity: sha512-kELo8ebBVtb9sA7rMe1Cph4QHreByhaZ2QEADd9NzIQsYNQpt9UkM9iqr2lhGr5afh885d/cB5QeTXSbZHTYPg==} + cpu: [s390x] + os: [linux] + + '@unrs/resolver-binding-linux-x64-gnu@1.11.1': + resolution: {integrity: sha512-C3ZAHugKgovV5YvAMsxhq0gtXuwESUKc5MhEtjBpLoHPLYM+iuwSj3lflFwK3DPm68660rZ7G8BMcwSro7hD5w==} + cpu: [x64] + os: [linux] + + '@unrs/resolver-binding-linux-x64-musl@1.11.1': + resolution: {integrity: sha512-rV0YSoyhK2nZ4vEswT/QwqzqQXw5I6CjoaYMOX0TqBlWhojUf8P94mvI7nuJTeaCkkds3QE4+zS8Ko+GdXuZtA==} + cpu: [x64] + os: [linux] + + '@unrs/resolver-binding-wasm32-wasi@1.11.1': + resolution: {integrity: sha512-5u4RkfxJm+Ng7IWgkzi3qrFOvLvQYnPBmjmZQ8+szTK/b31fQCnleNl1GgEt7nIsZRIf5PLhPwT0WM+q45x/UQ==} + engines: {node: '>=14.0.0'} + cpu: [wasm32] + + '@unrs/resolver-binding-win32-arm64-msvc@1.11.1': + resolution: {integrity: sha512-nRcz5Il4ln0kMhfL8S3hLkxI85BXs3o8EYoattsJNdsX4YUU89iOkVn7g0VHSRxFuVMdM4Q1jEpIId1Ihim/Uw==} + cpu: [arm64] + os: [win32] + + '@unrs/resolver-binding-win32-ia32-msvc@1.11.1': + resolution: {integrity: sha512-DCEI6t5i1NmAZp6pFonpD5m7i6aFrpofcp4LA2i8IIq60Jyo28hamKBxNrZcyOwVOZkgsRp9O2sXWBWP8MnvIQ==} + cpu: [ia32] + os: [win32] + + '@unrs/resolver-binding-win32-x64-msvc@1.11.1': + resolution: {integrity: sha512-lrW200hZdbfRtztbygyaq/6jP6AKE8qQN2KvPcJ+x7wiD038YtnYtZ82IMNJ69GJibV7bwL3y9FgK+5w/pYt6g==} + cpu: [x64] + os: [win32] + acorn-import-attributes@1.9.5: resolution: {integrity: sha512-n02Vykv5uA3eHGM/Z2dQrcD56kL8TyDb2p1+0P83PClMnC/nc+anbQRhIOWnSq4Ke/KvDPrY3C9hDtC/A3eHnQ==} peerDependencies: @@ -815,6 +931,10 @@ packages: commander@2.15.1: resolution: {integrity: sha512-VlfT9F3V0v+jr4yxPc5gg9s62/fIVWsd2Bk2iD435um1NlGMYdVCq+MjcXnhYq2icNOizHr1kK+5TI6H0Hy0ag==} + comment-parser@1.4.1: + resolution: {integrity: sha512-buhp5kePrmda3vhc5B9t7pUQXAb2Tnd0qgpkIhPhkHXxJpiPJ11H0ZEU0oBpJ2QztSbzG/ZxMj/CHsYJqRHmyg==} + engines: {node: '>= 12.0.0'} + concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} @@ -960,6 +1080,41 @@ packages: peerDependencies: eslint: '>=7.0.0' + eslint-import-context@0.1.9: + resolution: {integrity: sha512-K9Hb+yRaGAGUbwjhFNHvSmmkZs9+zbuoe3kFQ4V1wYjrepUFYM2dZAfNtjbbj3qsPfUfsA68Bx/ICWQMi+C8Eg==} + engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} + peerDependencies: + unrs-resolver: ^1.0.0 + peerDependenciesMeta: + unrs-resolver: + optional: true + + eslint-import-resolver-typescript@4.4.4: + resolution: {integrity: sha512-1iM2zeBvrYmUNTj2vSC/90JTHDth+dfOfiNKkxApWRsTJYNrc8rOdxxIf5vazX+BiAXTeOT0UvWpGI/7qIWQOw==} + engines: {node: ^16.17.0 || >=18.6.0} + peerDependencies: + eslint: '*' + eslint-plugin-import: '*' + eslint-plugin-import-x: '*' + peerDependenciesMeta: + eslint-plugin-import: + optional: true + eslint-plugin-import-x: + optional: true + + eslint-plugin-import-x@4.16.1: + resolution: {integrity: sha512-vPZZsiOKaBAIATpFE2uMI4w5IRwdv/FpQ+qZZMR4E+PeOcM4OeoEbqxRMnywdxP19TyB/3h6QBB0EWon7letSQ==} + engines: {node: ^18.18.0 || ^20.9.0 || >=21.1.0} + peerDependencies: + '@typescript-eslint/utils': ^8.0.0 + eslint: ^8.57.0 || ^9.0.0 + eslint-import-resolver-node: '*' + peerDependenciesMeta: + '@typescript-eslint/utils': + optional: true + eslint-import-resolver-node: + optional: true + eslint-plugin-prettier@5.5.3: resolution: {integrity: sha512-NAdMYww51ehKfDyDhv59/eIItUVzU0Io9H2E8nHNGKEeeqlnci+1gCvrHib6EmZdf6GxF+LCV5K7UC65Ezvw7w==} engines: {node: ^14.18.0 || >=16.0.0} @@ -1059,6 +1214,14 @@ packages: fclone@1.0.11: resolution: {integrity: sha512-GDqVQezKzRABdeqflsgMr7ktzgF9CyS+p2oe0jJqUY6izSSbhPIQJDpoU4PtGcD7VPM9xh/dVrTu6z1nwgmEGw==} + fdir@6.4.6: + resolution: {integrity: sha512-hiFoqpyZcfNm1yc4u8oWCf9A2c4D3QjCrks3zmoVKVxpQRzmPNar1hUJcBG2RQHvEVGDN+Jm81ZheVLAQMK6+w==} + peerDependencies: + picomatch: ^3 || ^4 + peerDependenciesMeta: + picomatch: + optional: true + fecha@4.2.3: resolution: {integrity: sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==} @@ -1152,6 +1315,9 @@ packages: resolution: {integrity: sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==} engines: {node: '>= 0.4'} + get-tsconfig@4.10.1: + resolution: {integrity: sha512-auHyJ4AgMz7vgS8Hp3N6HXSmlMdUyhSUrfBF16w153rxtLIEOE+HGqaBppczZvnHLqQJfiHotCYpNhl0lUROFQ==} + get-uri@6.0.5: resolution: {integrity: sha512-b1O07XYq8eRuVzBNgJLstU6FYc1tS6wnMtF1I1D9lE8LxZSOGZ7LhxN54yPP6mGw5f2CkXY2BQUL9Fx41qvcIg==} engines: {node: '>= 14'} @@ -1270,6 +1436,9 @@ packages: resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==} engines: {node: '>=8'} + is-bun-module@2.0.0: + resolution: {integrity: sha512-gNCGbnnnnFAUGKeZ9PdbyeGYJqewpmc2aKHUEMO5nQPWU9lOmv7jcmQIv+qHD8fXW6W7qfuCwX4rY9LNRjXrkQ==} + is-core-module@2.16.1: resolution: {integrity: sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==} engines: {node: '>= 0.4'} @@ -1426,6 +1595,11 @@ packages: napi-build-utils@2.0.0: resolution: {integrity: sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==} + napi-postinstall@0.3.3: + resolution: {integrity: sha512-uTp172LLXSxuSYHv/kou+f6KW3SMppU9ivthaVTXian9sOt3XM/zHYHpRZiLgQoxeWfYUnslNWQHF1+G71xcow==} + engines: {node: ^12.20.0 || ^14.18.0 || >=16.0.0} + hasBin: true + natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} @@ -1529,6 +1703,10 @@ packages: resolution: {integrity: sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==} engines: {node: '>=8.6'} + picomatch@4.0.3: + resolution: {integrity: sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==} + engines: {node: '>=12'} + pidusage@2.0.21: resolution: {integrity: sha512-cv3xAQos+pugVX+BfXpHsbyz/dLzX+lr44zNMsYiGxUw+kV5sgQCIcLd1z+0vq+KyC7dJ+/ts2PsfgWfSC3WXA==} engines: {node: '>=8'} @@ -1650,6 +1828,9 @@ packages: resolution: {integrity: sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==} engines: {node: '>=4'} + resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + resolve@1.22.10: resolution: {integrity: sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==} engines: {node: '>= 0.4'} @@ -1743,6 +1924,10 @@ packages: sprintf-js@1.1.3: resolution: {integrity: sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==} + stable-hash-x@0.2.0: + resolution: {integrity: sha512-o3yWv49B/o4QZk5ZcsALc6t0+eCelPc44zZsLtCQnZPDwFpDYSWcDnrv2TtMmMbQ7uKo3J0HTURCqckw23czNQ==} + engines: {node: '>=12.0.0'} + stack-trace@0.0.10: resolution: {integrity: sha512-KGzahc7puUKkzyMt+IqAep+TVNbKP+k2Lmwhub39m1AsTSkaDutx56aDCo+HLDzf/D26BIHTJWNiTG1KAJiQCg==} @@ -1801,6 +1986,10 @@ packages: text-hex@1.0.0: resolution: {integrity: sha512-uuVGNWzgJ4yhRaNSiubPY7OjISw4sw4E5Uv0wbjp+OzcbmVU/rsT8ujgcXJhn9ypzsgr5vlzpPqP+MBBKcGvbg==} + tinyglobby@0.2.14: + resolution: {integrity: sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==} + engines: {node: '>=12.0.0'} + to-regex-range@5.0.1: resolution: {integrity: sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==} engines: {node: '>=8.0'} @@ -1862,6 +2051,9 @@ packages: resolution: {integrity: sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==} engines: {node: '>= 10.0.0'} + unrs-resolver@1.11.1: + resolution: {integrity: sha512-bSjt9pjaEBnNiGgc9rUiHGKv5l4/TGzDmYw3RhnkJGtLhbnnA/5qJj7x3dNDCRx/PJxu774LlH8lCOlB4hEfKg==} + uri-js@4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} @@ -1968,6 +2160,22 @@ snapshots: enabled: 2.0.0 kuler: 2.0.0 + '@emnapi/core@1.4.5': + dependencies: + '@emnapi/wasi-threads': 1.0.4 + tslib: 2.8.1 + optional: true + + '@emnapi/runtime@1.4.5': + dependencies: + tslib: 2.8.1 + optional: true + + '@emnapi/wasi-threads@1.0.4': + dependencies: + tslib: 2.8.1 + optional: true + '@eslint-community/eslint-utils@4.7.0(eslint@9.32.0)': dependencies: eslint: 9.32.0 @@ -2066,6 +2274,13 @@ snapshots: dependencies: '@jsr/std__internal': 1.0.10 + '@napi-rs/wasm-runtime@0.2.12': + dependencies: + '@emnapi/core': 1.4.5 + '@emnapi/runtime': 1.4.5 + '@tybys/wasm-util': 0.10.0 + optional: true + '@nodelib/fs.scandir@2.1.5': dependencies: '@nodelib/fs.stat': 2.0.5 @@ -2522,6 +2737,11 @@ snapshots: '@tootallnate/quickjs-emscripten@0.23.0': optional: true + '@tybys/wasm-util@0.10.0': + dependencies: + tslib: 2.8.1 + optional: true + '@types/better-sqlite3@7.6.13': dependencies: '@types/node': 20.19.9 @@ -2677,6 +2897,65 @@ snapshots: '@typescript-eslint/types': 8.39.0 eslint-visitor-keys: 4.2.1 + '@unrs/resolver-binding-android-arm-eabi@1.11.1': + optional: true + + '@unrs/resolver-binding-android-arm64@1.11.1': + optional: true + + '@unrs/resolver-binding-darwin-arm64@1.11.1': + optional: true + + '@unrs/resolver-binding-darwin-x64@1.11.1': + optional: true + + '@unrs/resolver-binding-freebsd-x64@1.11.1': + optional: true + + '@unrs/resolver-binding-linux-arm-gnueabihf@1.11.1': + optional: true + + '@unrs/resolver-binding-linux-arm-musleabihf@1.11.1': + optional: true + + '@unrs/resolver-binding-linux-arm64-gnu@1.11.1': + optional: true + + '@unrs/resolver-binding-linux-arm64-musl@1.11.1': + optional: true + + '@unrs/resolver-binding-linux-ppc64-gnu@1.11.1': + optional: true + + '@unrs/resolver-binding-linux-riscv64-gnu@1.11.1': + optional: true + + '@unrs/resolver-binding-linux-riscv64-musl@1.11.1': + optional: true + + '@unrs/resolver-binding-linux-s390x-gnu@1.11.1': + optional: true + + '@unrs/resolver-binding-linux-x64-gnu@1.11.1': + optional: true + + '@unrs/resolver-binding-linux-x64-musl@1.11.1': + optional: true + + '@unrs/resolver-binding-wasm32-wasi@1.11.1': + dependencies: + '@napi-rs/wasm-runtime': 0.2.12 + optional: true + + '@unrs/resolver-binding-win32-arm64-msvc@1.11.1': + optional: true + + '@unrs/resolver-binding-win32-ia32-msvc@1.11.1': + optional: true + + '@unrs/resolver-binding-win32-x64-msvc@1.11.1': + optional: true + acorn-import-attributes@1.9.5(acorn@8.15.0): dependencies: acorn: 8.15.0 @@ -2921,6 +3200,8 @@ snapshots: commander@2.15.1: optional: true + comment-parser@1.4.1: {} + concat-map@0.0.1: {} console-control-strings@1.1.0: {} @@ -3040,6 +3321,45 @@ snapshots: dependencies: eslint: 9.32.0 + eslint-import-context@0.1.9(unrs-resolver@1.11.1): + dependencies: + get-tsconfig: 4.10.1 + stable-hash-x: 0.2.0 + optionalDependencies: + unrs-resolver: 1.11.1 + + eslint-import-resolver-typescript@4.4.4(eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.39.0(eslint@9.32.0)(typescript@5.9.2))(eslint@9.32.0))(eslint@9.32.0): + dependencies: + debug: 4.4.1 + eslint: 9.32.0 + eslint-import-context: 0.1.9(unrs-resolver@1.11.1) + get-tsconfig: 4.10.1 + is-bun-module: 2.0.0 + stable-hash-x: 0.2.0 + tinyglobby: 0.2.14 + unrs-resolver: 1.11.1 + optionalDependencies: + eslint-plugin-import-x: 4.16.1(@typescript-eslint/utils@8.39.0(eslint@9.32.0)(typescript@5.9.2))(eslint@9.32.0) + transitivePeerDependencies: + - supports-color + + eslint-plugin-import-x@4.16.1(@typescript-eslint/utils@8.39.0(eslint@9.32.0)(typescript@5.9.2))(eslint@9.32.0): + dependencies: + '@typescript-eslint/types': 8.39.0 + comment-parser: 1.4.1 + debug: 4.4.1 + eslint: 9.32.0 + eslint-import-context: 0.1.9(unrs-resolver@1.11.1) + is-glob: 4.0.3 + minimatch: 9.0.5 + semver: 7.7.2 + stable-hash-x: 0.2.0 + unrs-resolver: 1.11.1 + optionalDependencies: + '@typescript-eslint/utils': 8.39.0(eslint@9.32.0)(typescript@5.9.2) + transitivePeerDependencies: + - supports-color + eslint-plugin-prettier@5.5.3(eslint-config-prettier@10.1.8(eslint@9.32.0))(eslint@9.32.0)(prettier@3.6.2): dependencies: eslint: 9.32.0 @@ -3160,6 +3480,10 @@ snapshots: fclone@1.0.11: optional: true + fdir@6.4.6(picomatch@4.0.3): + optionalDependencies: + picomatch: 4.0.3 + fecha@4.2.3: {} fflate@0.8.2: {} @@ -3271,6 +3595,10 @@ snapshots: dunder-proto: 1.0.1 es-object-atoms: 1.1.1 + get-tsconfig@4.10.1: + dependencies: + resolve-pkg-maps: 1.0.0 + get-uri@6.0.5: dependencies: basic-ftp: 5.0.5 @@ -3383,6 +3711,10 @@ snapshots: binary-extensions: 2.3.0 optional: true + is-bun-module@2.0.0: + dependencies: + semver: 7.7.2 + is-core-module@2.16.1: dependencies: hasown: 2.0.2 @@ -3527,6 +3859,8 @@ snapshots: napi-build-utils@2.0.0: {} + napi-postinstall@0.3.3: {} + natural-compare@1.4.0: {} needle@2.4.0: @@ -3647,6 +3981,8 @@ snapshots: picomatch@2.3.1: {} + picomatch@4.0.3: {} + pidusage@2.0.21: dependencies: safe-buffer: 5.2.1 @@ -3849,6 +4185,8 @@ snapshots: resolve-from@4.0.0: {} + resolve-pkg-maps@1.0.0: {} + resolve@1.22.10: dependencies: is-core-module: 2.16.1 @@ -3947,6 +4285,8 @@ snapshots: sprintf-js@1.1.3: optional: true + stable-hash-x@0.2.0: {} + stack-trace@0.0.10: {} string-width@4.2.3: @@ -4011,6 +4351,11 @@ snapshots: text-hex@1.0.0: {} + tinyglobby@0.2.14: + dependencies: + fdir: 6.4.6(picomatch@4.0.3) + picomatch: 4.0.3 + to-regex-range@5.0.1: dependencies: is-number: 7.0.0 @@ -4066,6 +4411,30 @@ snapshots: universalify@2.0.1: {} + unrs-resolver@1.11.1: + dependencies: + napi-postinstall: 0.3.3 + optionalDependencies: + '@unrs/resolver-binding-android-arm-eabi': 1.11.1 + '@unrs/resolver-binding-android-arm64': 1.11.1 + '@unrs/resolver-binding-darwin-arm64': 1.11.1 + '@unrs/resolver-binding-darwin-x64': 1.11.1 + '@unrs/resolver-binding-freebsd-x64': 1.11.1 + '@unrs/resolver-binding-linux-arm-gnueabihf': 1.11.1 + '@unrs/resolver-binding-linux-arm-musleabihf': 1.11.1 + '@unrs/resolver-binding-linux-arm64-gnu': 1.11.1 + '@unrs/resolver-binding-linux-arm64-musl': 1.11.1 + '@unrs/resolver-binding-linux-ppc64-gnu': 1.11.1 + '@unrs/resolver-binding-linux-riscv64-gnu': 1.11.1 + '@unrs/resolver-binding-linux-riscv64-musl': 1.11.1 + '@unrs/resolver-binding-linux-s390x-gnu': 1.11.1 + '@unrs/resolver-binding-linux-x64-gnu': 1.11.1 + '@unrs/resolver-binding-linux-x64-musl': 1.11.1 + '@unrs/resolver-binding-wasm32-wasi': 1.11.1 + '@unrs/resolver-binding-win32-arm64-msvc': 1.11.1 + '@unrs/resolver-binding-win32-ia32-msvc': 1.11.1 + '@unrs/resolver-binding-win32-x64-msvc': 1.11.1 + uri-js@4.4.1: dependencies: punycode: 2.3.1 diff --git a/src/api/index.ts b/src/api/index.ts index 5dc23530..50ae179b 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -4,7 +4,7 @@ import EventEmitter from "node:events"; import { createServer } from "node:http"; import process from "node:process"; import { DiscordRESTError, type RawMessage } from "oceanic.js"; -import type WebSocket from "ws"; +import type WSocket from "ws"; import { WebSocketServer, type ErrorEvent } from "ws"; import run from "#utils/image-runner.js"; import { img } from "#utils/imageLib.js"; @@ -91,7 +91,7 @@ const discordBaseURL = /** * Accept an image job. */ -async function acceptJob(id: bigint, sock: WebSocket): Promise { +async function acceptJob(id: bigint, sock: WSocket): Promise { const job = jobs.get(id); try { await runJob( @@ -348,7 +348,7 @@ async function finishJob( data: { buffer: Buffer; fileExtension: string }, job: MiniJob, object: ImageParams, - ws: WebSocket, + ws: WSocket, ) { log(`Sending result of job ${job.id}`, job.num); const jobObject = jobs.get(job.id); @@ -410,7 +410,7 @@ async function finishJob( /** * Run an image job. */ -async function runJob(job: MiniJob, ws: WebSocket): Promise { +async function runJob(job: MiniJob, ws: WSocket): Promise { log(`Job ${job.id} starting...`, job.num); const object = job.msg; diff --git a/src/app.ts b/src/app.ts index 2a399b4d..b4ec9218 100644 --- a/src/app.ts +++ b/src/app.ts @@ -1,3 +1,6 @@ +// eslint-disable-next-line import-x/order +import process from "node:process"; + const [major] = process.versions.node.split(".").map(Number); if (major < 22) { console.error(`You are currently running Node.js version ${process.versions.node}. @@ -19,8 +22,6 @@ esmBot will continue to run past this message in 5 seconds, but keep in mind tha // load config from .env file import "dotenv/config"; -import process from "node:process"; - if (process.env.SENTRY_DSN && process.env.SENTRY_DSN !== "") await import("./utils/sentry.ts"); if (!process.env.TOKEN) { @@ -40,10 +41,8 @@ import { glob, readFile } from "node:fs/promises"; import { dirname, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { promisify } from "node:util"; - import { Client, type ClientEvents, Constants } from "oceanic.js"; - -import { init as dbInit } from "./database.ts"; +import commandConfig from "#config/commands.json" with { type: "json" }; import { locales, paths } from "#utils/collections.js"; import detectRuntime from "#utils/detectRuntime.js"; import { load } from "#utils/handler.js"; @@ -52,9 +51,9 @@ import logger from "#utils/logger.js"; import { endBroadcast, exit, startBroadcast } from "#utils/misc.js"; import { connect, connected, reload } from "#utils/soundplayer.js"; import { parseThreshold } from "#utils/tempimages.js"; - -import commandConfig from "#config/commands.json" with { type: "json" }; import packageJson from "../package.json" with { type: "json" }; +import { init as dbInit } from "./database.ts"; + process.env.ESMBOT_VER = packageJson.version; const intents = [Constants.Intents.GUILD_VOICE_STATES, Constants.Intents.DIRECT_MESSAGES, Constants.Intents.GUILDS]; diff --git a/src/classes/musicCommand.ts b/src/classes/musicCommand.ts index c3fa1dee..5995935f 100644 --- a/src/classes/musicCommand.ts +++ b/src/classes/musicCommand.ts @@ -1,7 +1,7 @@ import type { Client } from "oceanic.js"; import { type QueueEntry, type SoundPlayer, players, queues } from "#utils/soundplayer.js"; -import Command, { type CommandOptions } from "./command.ts"; import type { DatabasePlugin } from "../database.ts"; +import Command, { type CommandOptions } from "./command.ts"; class MusicCommand extends Command { connection?: SoundPlayer; diff --git a/src/database/postgresql.ts b/src/database/postgresql.ts index 2c9a317c..cebaa07e 100644 --- a/src/database/postgresql.ts +++ b/src/database/postgresql.ts @@ -1,6 +1,6 @@ import process from "node:process"; import type { Guild, GuildChannel } from "oceanic.js"; -import type { DatabasePlugin } from "../database.ts"; +import Postgres from "postgres"; import { commands, disabledCache, @@ -11,8 +11,7 @@ import { } from "#utils/collections.js"; import logger from "#utils/logger.js"; import type { Count, DBGuild, Tag } from "#utils/types.js"; - -import Postgres from "postgres"; +import type { DatabasePlugin } from "../database.ts"; interface Settings { id: number; diff --git a/src/database/sqlite.ts b/src/database/sqlite.ts index 3f6d5966..6db13f8e 100644 --- a/src/database/sqlite.ts +++ b/src/database/sqlite.ts @@ -1,13 +1,12 @@ -import type { Database as DenoDatabase, Statement as DenoStatement } from "@db/sqlite"; -import type { Database as BunDatabase, Statement as BunStatement } from "bun:sqlite"; import process from "node:process"; +import type { Database as DenoDatabase, Statement as DenoStatement } from "@db/sqlite"; import type { Database as BSQLite3Database, Options as BSQLite3Options, Statement as BSQLite3Statement, } from "better-sqlite3"; +import type { Database as BunDatabase, Statement as BunStatement } from "bun:sqlite"; import type { Guild, GuildChannel } from "oceanic.js"; -import type { DatabasePlugin } from "../database.ts"; import { commands, disabledCache, @@ -18,6 +17,7 @@ import { } from "#utils/collections.js"; import logger from "#utils/logger.js"; import type { Count, DBGuild, Tag } from "#utils/types.js"; +import type { DatabasePlugin } from "../database.ts"; type BunDenoDatabase = typeof BunDatabase | typeof DenoDatabase; diff --git a/src/events/ready.ts b/src/events/ready.ts index 2fc26a2d..b2b8bc60 100644 --- a/src/events/ready.ts +++ b/src/events/ready.ts @@ -1,11 +1,10 @@ import process from "node:process"; +import commandsConfig from "#config/commands.json" with { type: "json" }; import { send } from "#utils/handler.js"; import { createPage, generateList } from "#utils/help.js"; import logger from "#utils/logger.js"; import { activityChanger, checkBroadcast } from "#utils/misc.js"; import type { EventParams } from "#utils/types.js"; - -import commandsConfig from "#config/commands.json" with { type: "json" }; let ready = false; export default async ({ client, database }: EventParams) => { diff --git a/src/events/voiceChannelSwitch.ts b/src/events/voiceChannelSwitch.ts index 4aa978ee..b60b4d32 100644 --- a/src/events/voiceChannelSwitch.ts +++ b/src/events/voiceChannelSwitch.ts @@ -1,6 +1,6 @@ import type { Member, StageChannel, Uncached, VoiceChannel } from "oceanic.js"; -import leaveHandler from "./voiceChannelLeave.ts"; import type { EventParams } from "#utils/types.js"; +import leaveHandler from "./voiceChannelLeave.ts"; export default async ( params: EventParams, diff --git a/src/utils/handler.ts b/src/utils/handler.ts index 74d14d6e..4f284693 100644 --- a/src/utils/handler.ts +++ b/src/utils/handler.ts @@ -1,7 +1,6 @@ +import { dirname, relative, resolve } from "node:path"; import process from "node:process"; -import { aliases, categories, commands, info, messageCommands, paths, userCommands } from "./collections.ts"; -import { log } from "./logger.ts"; - +import { fileURLToPath } from "node:url"; import { deepmergeInto } from "deepmerge-ts"; import { type Client, @@ -11,10 +10,10 @@ import { } from "oceanic.js"; import Command from "#cmd-classes/command.js"; import commandConfig from "#config/commands.json" with { type: "json" }; +import { aliases, categories, commands, info, messageCommands, paths, userCommands } from "./collections.ts"; import { getAllLocalizations } from "./i18n.ts"; +import { log } from "./logger.ts"; import type { CommandEntry, CommandInfo, CommandsConfig, ExtendedCommandOptions, Param } from "./types.ts"; -import { dirname, relative, resolve } from "node:path"; -import { fileURLToPath } from "node:url"; let queryValue = 0; diff --git a/src/utils/help.ts b/src/utils/help.ts index 541c2bf8..14464133 100644 --- a/src/utils/help.ts +++ b/src/utils/help.ts @@ -1,9 +1,9 @@ import { promises } from "node:fs"; import process from "node:process"; +import { Constants } from "oceanic.js"; import commandConfig from "#config/commands.json" with { type: "json" }; import { info } from "./collections.ts"; import type { Param } from "./types.ts"; -import { Constants } from "oceanic.js"; export const categoryTemplate = { general: [], diff --git a/src/utils/image.ts b/src/utils/image.ts index acfe7ffa..5703ecd4 100644 --- a/src/utils/image.ts +++ b/src/utils/image.ts @@ -5,11 +5,12 @@ import { createRequire } from "node:module"; import process from "node:process"; import { fileTypeFromBuffer } from "file-type"; import ipaddr from "ipaddr.js"; +import serversConfig from "#config/servers.json" with { type: "json" }; import ImageConnection from "./imageConnection.ts"; import logger from "./logger.ts"; import { random } from "./misc.ts"; import type { ImageParams, ImageTypeData } from "./types.ts"; -import serversConfig from "#config/servers.json" with { type: "json" }; + const run = process.env.API_TYPE === "ws" ? null : (await import("../utils/image-runner.ts")).default; let img: import("./imageLib.ts").ImageLib | undefined; diff --git a/src/utils/imageConnection.ts b/src/utils/imageConnection.ts index 42e55a79..f3917ef9 100644 --- a/src/utils/imageConnection.ts +++ b/src/utils/imageConnection.ts @@ -1,6 +1,6 @@ import { Buffer } from "node:buffer"; import { setTimeout } from "node:timers/promises"; -import WebSocket, { type Data, type ErrorEvent } from "ws"; +import WSocket, { type Data, type ErrorEvent } from "ws"; import logger from "./logger.ts"; const Rerror = 0x01; @@ -34,7 +34,7 @@ class ImageConnection { funcs: string[]; wsproto: string; sockurl: string; - conn: WebSocket; + conn: WSocket; httpurl: string; reconnect?: boolean; constructor(host: string, auth?: string, name?: string, tls = false) { @@ -56,7 +56,7 @@ class ImageConnection { if (auth) { headers.Authentication = auth; } - this.conn = new WebSocket(this.sockurl, { headers }); + this.conn = new WSocket(this.sockurl, { headers }); this.conn.binaryType = "nodebuffer"; let httpproto: string; if (tls) { @@ -120,7 +120,7 @@ class ImageConnection { `${this.reconnect ? `${this.host} requested a reconnect` : `Lost connection to ${this.host}`}, attempting to reconnect in 5 seconds...`, ); await setTimeout(5000); - this.conn = new WebSocket(this.sockurl, { + this.conn = new WSocket(this.sockurl, { headers: { Authentication: this.auth, }, diff --git a/src/utils/misc.ts b/src/utils/misc.ts index 53b079cb..f0789c4f 100644 --- a/src/utils/misc.ts +++ b/src/utils/misc.ts @@ -1,14 +1,17 @@ -import util from "node:util"; import process from "node:process"; -const pm2 = process.env.PM2_USAGE ? (await import("pm2")).default : null; +import util from "node:util"; + import { type DotenvParseOutput, config } from "dotenv"; import type { AnyChannel, AnyPrivateChannel, Client, CommandInteraction, Message } from "oceanic.js"; -import type { DatabasePlugin } from "../database.ts"; -import { disconnect, servers } from "./image.ts"; import commandsConfig from "#config/commands.json" with { type: "json" }; import messagesConfig from "#config/messages.json" with { type: "json" }; +import type { DatabasePlugin } from "../database.ts"; +import { disconnect, servers } from "./image.ts"; + +const pm2 = process.env.PM2_USAGE ? (await import("pm2")).default : null; + let broadcast = false; // random(array) to select a random entry in array diff --git a/src/utils/tempimages.ts b/src/utils/tempimages.ts index d5505df7..d357bf2e 100644 --- a/src/utils/tempimages.ts +++ b/src/utils/tempimages.ts @@ -1,5 +1,6 @@ import { lstat, readdir, rm, stat, writeFile } from "node:fs/promises"; import process from "node:process"; + import { type Client, CommandInteraction, @@ -9,10 +10,11 @@ import { type Message, MessageFlags, } from "oceanic.js"; -import { getString } from "./i18n.ts"; -import logger from "./logger.ts"; + import { selectedImages } from "./collections.ts"; +import { getString } from "./i18n.ts"; import { getType } from "./image.ts"; +import logger from "./logger.ts"; type SizeSuffix = "K" | "M" | "G" | "T"; type FileStats = { diff --git a/src/utils/types.ts b/src/utils/types.ts index 9fed2c49..1c24eaff 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -1,6 +1,6 @@ import type { ApplicationCommandOptions, Client, Constants } from "oceanic.js"; -import type { DatabasePlugin } from "../database.ts"; import type Command from "#cmd-classes/command.js"; +import type { DatabasePlugin } from "../database.ts"; export interface DBGuild { guild_id: string;