Merge branch 'e621ng:master' into try-not-to-spell-challenge

This commit is contained in:
2026-06-06 00:41:00 +08:00
committed by GitHub
15 changed files with 411 additions and 76 deletions
+1
View File
@@ -0,0 +1 @@
@clynamic:registry=https://npm.clynamic.net
+10 -7
View File
@@ -1,11 +1,11 @@
const eslint = require('@eslint/js'); import eslint from '@eslint/js';
const globals = require('globals'); import globals from 'globals';
const tseslint = require('typescript-eslint'); import tseslint from 'typescript-eslint';
const stylistic = require('@stylistic/eslint-plugin'); import stylistic from '@stylistic/eslint-plugin';
const ignores = ['dist/**/*', 'node_modules/**/*', 'eslint.config.js']; const ignores = ['dist/**/*', 'node_modules/**/*'];
module.exports = tseslint.config( const config = tseslint.config(
{ {
ignores, ignores,
extends: [ extends: [
@@ -65,4 +65,7 @@ module.exports = tseslint.config(
'@typescript-eslint/no-namespace': 'off', '@typescript-eslint/no-namespace': 'off',
}, },
} }
); );
export default config;
+266 -8
View File
@@ -5,7 +5,7 @@
"packages": { "packages": {
"": { "": {
"dependencies": { "dependencies": {
"@clynamic/dmark": "0.0.7", "@clynamic/dmark": "0.0.8",
"@redis/client": "5.1.0", "@redis/client": "5.1.0",
"body-parser": "2.2.2", "body-parser": "2.2.2",
"discord.js": "14.26.4", "discord.js": "14.26.4",
@@ -24,19 +24,17 @@
"@types/express-session": "1.18.1", "@types/express-session": "1.18.1",
"eslint": "9.27.0", "eslint": "9.27.0",
"rimraf": "6.0.1", "rimraf": "6.0.1",
"tsc-alias": "1.8.17",
"tsx": "4.19.4", "tsx": "4.19.4",
"typescript": "5.8.3", "typescript": "5.8.3",
"typescript-eslint": "8.32.1" "typescript-eslint": "8.32.1"
} }
}, },
"node_modules/@clynamic/dmark": { "node_modules/@clynamic/dmark": {
"version": "0.0.7", "version": "0.0.8",
"resolved": "https://npm.clynamic.net/%40clynamic%2Fdmark/-/0.0.7/dmark-0.0.7.tgz", "resolved": "https://npm.clynamic.net/%40clynamic%2Fdmark/-/0.0.8/dmark-0.0.8.tgz",
"integrity": "sha512-sz/rf0kSUkprTVFO+3dQjHg+jxbtfcqmWIVcSvsYU7Uz6ywAAd5RI4igZ7bsBGrOfXcgyEKRE6/XjygYHKPjQA==", "integrity": "sha512-KzZqTeWldrB2ij74s5hVUVdHaBur4QqYExv6V9mSiTovdcspbRS0pA5v6OwONdxvcBou7b4p4cIalNj4eARgxg==",
"license": "UNLICENSED", "license": "UNLICENSED"
"dependencies": {
"markdown-it": "^14.1.1"
}
}, },
"node_modules/@discordjs/builders": { "node_modules/@discordjs/builders": {
"version": "1.14.1", "version": "1.14.1",
@@ -1348,11 +1346,48 @@
"url": "https://github.com/chalk/ansi-styles?sponsor=1" "url": "https://github.com/chalk/ansi-styles?sponsor=1"
} }
}, },
"node_modules/anymatch": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
"integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
"dev": true,
"license": "ISC",
"dependencies": {
"normalize-path": "^3.0.0",
"picomatch": "^2.0.4"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/anymatch/node_modules/picomatch": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
"integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8.6"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/argparse": { "node_modules/argparse": {
"version": "2.0.1", "version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==" "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
}, },
"node_modules/array-union": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz",
"integrity": "sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/balanced-match": { "node_modules/balanced-match": {
"version": "1.0.2", "version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
@@ -1378,6 +1413,19 @@
} }
] ]
}, },
"node_modules/binary-extensions": {
"version": "2.3.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.3.0.tgz",
"integrity": "sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/bindings": { "node_modules/bindings": {
"version": "1.5.0", "version": "1.5.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz", "resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
@@ -1543,6 +1591,44 @@
"url": "https://github.com/chalk/chalk?sponsor=1" "url": "https://github.com/chalk/chalk?sponsor=1"
} }
}, },
"node_modules/chokidar": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz",
"integrity": "sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==",
"dev": true,
"license": "MIT",
"dependencies": {
"anymatch": "~3.1.2",
"braces": "~3.0.2",
"glob-parent": "~5.1.2",
"is-binary-path": "~2.1.0",
"is-glob": "~4.0.1",
"normalize-path": "~3.0.0",
"readdirp": "~3.6.0"
},
"engines": {
"node": ">= 8.10.0"
},
"funding": {
"url": "https://paulmillr.com/funding/"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
}
},
"node_modules/chokidar/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/chownr": { "node_modules/chownr": {
"version": "3.0.0", "version": "3.0.0",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz", "resolved": "https://registry.npmjs.org/chownr/-/chownr-3.0.0.tgz",
@@ -1578,6 +1664,16 @@
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true "dev": true
}, },
"node_modules/commander": {
"version": "9.5.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-9.5.0.tgz",
"integrity": "sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": "^12.20.0 || >=14"
}
},
"node_modules/concat-map": { "node_modules/concat-map": {
"version": "0.0.1", "version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@@ -1694,6 +1790,19 @@
"node": ">=8" "node": ">=8"
} }
}, },
"node_modules/dir-glob": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/dir-glob/-/dir-glob-3.0.1.tgz",
"integrity": "sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==",
"dev": true,
"license": "MIT",
"dependencies": {
"path-type": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/discord-api-types": { "node_modules/discord-api-types": {
"version": "0.38.42", "version": "0.38.42",
"resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.42.tgz", "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.38.42.tgz",
@@ -2429,6 +2538,27 @@
"url": "https://github.com/sponsors/sindresorhus" "url": "https://github.com/sponsors/sindresorhus"
} }
}, },
"node_modules/globby": {
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
"dev": true,
"license": "MIT",
"dependencies": {
"array-union": "^2.1.0",
"dir-glob": "^3.0.1",
"fast-glob": "^3.2.9",
"ignore": "^5.2.0",
"merge2": "^1.4.1",
"slash": "^3.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/gopd": { "node_modules/gopd": {
"version": "1.2.0", "version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
@@ -2575,6 +2705,19 @@
"node": ">= 0.10" "node": ">= 0.10"
} }
}, },
"node_modules/is-binary-path": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
"dev": true,
"license": "MIT",
"dependencies": {
"binary-extensions": "^2.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/is-extglob": { "node_modules/is-extglob": {
"version": "2.1.1", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@@ -2940,6 +3083,20 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
}, },
"node_modules/mylas": {
"version": "2.1.14",
"resolved": "https://registry.npmjs.org/mylas/-/mylas-2.1.14.tgz",
"integrity": "sha512-BzQguy9W9NJgoVn2mRWzbFrFWWztGCcng2QI9+41frfk+Athwgx3qhqhvStz7ExeUUu7Kzw427sNzHpEZNINog==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=16.0.0"
},
"funding": {
"type": "github",
"url": "https://github.com/sponsors/raouldeheer"
}
},
"node_modules/napi-build-utils": { "node_modules/napi-build-utils": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-2.0.0.tgz", "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-2.0.0.tgz",
@@ -3048,6 +3205,16 @@
"node": "^20.17.0 || >=22.9.0" "node": "^20.17.0 || >=22.9.0"
} }
}, },
"node_modules/normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/object-inspect": { "node_modules/object-inspect": {
"version": "1.13.4", "version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz", "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
@@ -3188,6 +3355,16 @@
"url": "https://opencollective.com/express" "url": "https://opencollective.com/express"
} }
}, },
"node_modules/path-type": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-type/-/path-type-4.0.0.tgz",
"integrity": "sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/picomatch": { "node_modules/picomatch": {
"version": "4.0.4", "version": "4.0.4",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.4.tgz",
@@ -3201,6 +3378,19 @@
"url": "https://github.com/sponsors/jonschlinkert" "url": "https://github.com/sponsors/jonschlinkert"
} }
}, },
"node_modules/plimit-lit": {
"version": "1.6.1",
"resolved": "https://registry.npmjs.org/plimit-lit/-/plimit-lit-1.6.1.tgz",
"integrity": "sha512-B7+VDyb8Tl6oMJT9oSO2CW8XC/T4UcJGrwOVoNGwOQsQYhlpfajmrMj5xeejqaASq3V/EqThyOeATEOMuSEXiA==",
"dev": true,
"license": "MIT",
"dependencies": {
"queue-lit": "^1.5.1"
},
"engines": {
"node": ">=12"
}
},
"node_modules/prebuild-install": { "node_modules/prebuild-install": {
"version": "7.1.3", "version": "7.1.3",
"resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.3.tgz", "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-7.1.3.tgz",
@@ -3305,6 +3495,16 @@
"url": "https://github.com/sponsors/ljharb" "url": "https://github.com/sponsors/ljharb"
} }
}, },
"node_modules/queue-lit": {
"version": "1.5.2",
"resolved": "https://registry.npmjs.org/queue-lit/-/queue-lit-1.5.2.tgz",
"integrity": "sha512-tLc36IOPeMAubu8BkW8YDBV+WyIgKlYU7zUNs0J5Vk9skSZ4JfGlPOqplP0aHdfv7HL0B2Pg6nwiq60Qc6M2Hw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=12"
}
},
"node_modules/queue-microtask": { "node_modules/queue-microtask": {
"version": "1.2.3", "version": "1.2.3",
"resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz", "resolved": "https://registry.npmjs.org/queue-microtask/-/queue-microtask-1.2.3.tgz",
@@ -3407,6 +3607,32 @@
"node": ">= 6" "node": ">= 6"
} }
}, },
"node_modules/readdirp": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
"dev": true,
"license": "MIT",
"dependencies": {
"picomatch": "^2.2.1"
},
"engines": {
"node": ">=8.10.0"
}
},
"node_modules/readdirp/node_modules/picomatch": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.2.tgz",
"integrity": "sha512-V7+vQEJ06Z+c5tSye8S+nHUfI51xoXIXjHQ99cQtKUkQqqO1kO/KCJUfZXuB47h/YBlDhah2H3hdUGXn8ie0oA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8.6"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/resolve-from": { "node_modules/resolve-from": {
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz",
@@ -3819,6 +4045,16 @@
"simple-concat": "^1.0.0" "simple-concat": "^1.0.0"
} }
}, },
"node_modules/slash": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz",
"integrity": "sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/sqlite": { "node_modules/sqlite": {
"version": "5.1.1", "version": "5.1.1",
"resolved": "https://registry.npmjs.org/sqlite/-/sqlite-5.1.1.tgz", "resolved": "https://registry.npmjs.org/sqlite/-/sqlite-5.1.1.tgz",
@@ -4090,6 +4326,28 @@
"integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==", "integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==",
"license": "MIT" "license": "MIT"
}, },
"node_modules/tsc-alias": {
"version": "1.8.17",
"resolved": "https://registry.npmjs.org/tsc-alias/-/tsc-alias-1.8.17.tgz",
"integrity": "sha512-EIduCZHqbNwPm8BZYfq1aD7BQ697A4h6uSGMOFQfYGoQwfrYFTKwYfy9Bv42YxHkduVBcn9Zx0DkX111DKskyg==",
"dev": true,
"license": "MIT",
"dependencies": {
"chokidar": "^3.5.3",
"commander": "^9.0.0",
"get-tsconfig": "^4.10.0",
"globby": "^11.0.4",
"mylas": "^2.1.9",
"normalize-path": "^3.0.0",
"plimit-lit": "^1.2.6"
},
"bin": {
"tsc-alias": "dist/bin/index.js"
},
"engines": {
"node": ">=16.20.2"
}
},
"node_modules/tslib": { "node_modules/tslib": {
"version": "2.8.1", "version": "2.8.1",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz",
+3 -2
View File
@@ -7,12 +7,13 @@
"@types/express-session": "1.18.1", "@types/express-session": "1.18.1",
"eslint": "9.27.0", "eslint": "9.27.0",
"rimraf": "6.0.1", "rimraf": "6.0.1",
"tsc-alias": "1.8.17",
"tsx": "4.19.4", "tsx": "4.19.4",
"typescript": "5.8.3", "typescript": "5.8.3",
"typescript-eslint": "8.32.1" "typescript-eslint": "8.32.1"
}, },
"dependencies": { "dependencies": {
"@clynamic/dmark": "0.0.7", "@clynamic/dmark": "0.0.8",
"@redis/client": "5.1.0", "@redis/client": "5.1.0",
"body-parser": "2.2.2", "body-parser": "2.2.2",
"discord.js": "14.26.4", "discord.js": "14.26.4",
@@ -27,7 +28,7 @@
"scripts": { "scripts": {
"dev": "tsx watch --enable-source-maps src/index.ts", "dev": "tsx watch --enable-source-maps src/index.ts",
"start": "node dist/index.js", "start": "node dist/index.js",
"build": "npm run clean && npx tsc && npm run copyfiles", "build": "npm run clean && npx tsc && npx tsc-alias && npm run copyfiles",
"clean": "npx rimraf dist", "clean": "npx rimraf dist",
"copyfiles": "npx copyfiles -u 1 \"./src/**/*.html\" ./dist" "copyfiles": "npx copyfiles -u 1 \"./src/**/*.html\" ./dist"
} }
+1
View File
@@ -50,6 +50,7 @@ const regexTesters = [
const uniqueRegexMatches = (g, i, a) => a.findIndex(v => v[1] == g[1]) == i; const uniqueRegexMatches = (g, i, a) => a.findIndex(v => v[1] == g[1]) == i;
export async function handleMessageCreate(message: Message) { export async function handleMessageCreate(message: Message) {
console.log('message created');
if (message.author.bot) return; if (message.author.bot) return;
if (message.inGuild()) await Database.putMessage(message); if (message.inGuild()) await Database.putMessage(message);
+11 -10
View File
@@ -140,20 +140,21 @@ client.on('clientReady', async () => {
ScheduledTasks.forEach(task => scheduler.add(task)); ScheduledTasks.forEach(task => scheduler.add(task));
client.on('guildAuditLogEntryCreate', handleAuditLogCreate);
client.on('guildBanRemove', handleBanRemove);
client.on('guildCreate', handleGuildCreate);
client.on('guildMemberAdd', handleMemberJoin);
client.on('messageCreate', handleMessageCreate);
client.on('messageDelete', handleMessageDelete);
client.on('messageDeleteBulk', handleBulkMessageDelete);
client.on('messageUpdate', handleMessageUpdate);
client.on('threadCreate', handleThreadCreate);
client.on('voiceStateUpdate', handleVoiceStateUpdate);
ready = true; ready = true;
console.log('Ready'); console.log('Ready');
}); });
client.on('guildAuditLogEntryCreate', handleAuditLogCreate);
client.on('guildBanRemove', handleBanRemove);
client.on('guildCreate', handleGuildCreate);
client.on('guildMemberAdd', handleMemberJoin);
client.on('messageCreate', handleMessageCreate);
client.on('messageDelete', handleMessageDelete);
client.on('messageDeleteBulk', handleBulkMessageDelete);
client.on('messageUpdate', handleMessageUpdate);
client.on('threadCreate', handleThreadCreate);
client.on('voiceStateUpdate', handleVoiceStateUpdate);
client.on('error', console.error); client.on('error', console.error);
process.on('uncaughtException', console.error); process.on('uncaughtException', console.error);
+26
View File
@@ -122,6 +122,8 @@ export class Database {
static async open(file: string): Promise<void> { static async open(file: string): Promise<void> {
if (Database.db) return; if (Database.db) return;
console.log('Opening SQLite database');
Database.db = await open({ Database.db = await open({
filename: file, filename: file,
driver: sqlite3.Database driver: sqlite3.Database
@@ -282,6 +284,18 @@ export class Database {
await Database.db.run('INSERT INTO tickets(id, message_id) VALUES (?, ?)', ticketId, messageId); await Database.db.run('INSERT INTO tickets(id, message_id) VALUES (?, ?)', ticketId, messageId);
} }
static async updateTicketMessageId(ticketId: number, messageId: string) {
await Database.db.run('UPDATE tickets SET message_id = ? WHERE id = ?', messageId, ticketId);
}
static async putTicketOrUpdate(ticketId: number, messageId: string) {
if (await Database.getTicketMessageId(ticketId)) {
await Database.updateTicketMessageId(ticketId, messageId);
} else {
await Database.putTicket(ticketId, messageId);
}
}
static async removeTicket(ticketId: number) { static async removeTicket(ticketId: number) {
await Database.db.run('DELETE from tickets WHERE id = ?', ticketId); await Database.db.run('DELETE from tickets WHERE id = ?', ticketId);
} }
@@ -327,6 +341,18 @@ export class Database {
await Database.db.run('INSERT INTO appeals(id, message_id) VALUES (?, ?)', appealId, messageId); await Database.db.run('INSERT INTO appeals(id, message_id) VALUES (?, ?)', appealId, messageId);
} }
static async updateAppealMessageId(appealId: number, messageId: string) {
await Database.db.run('UPDATE appeals SET message_id = ? WHERE id = ?', messageId, appealId);
}
static async putAppealOrUpdate(ticketId: number, messageId: string) {
if (await Database.getAppealMessageId(ticketId)) {
await Database.updateAppealMessageId(ticketId, messageId);
} else {
await Database.putAppeal(ticketId, messageId);
}
}
static async removeAppeal(appealId: number) { static async removeAppeal(appealId: number) {
await Database.db.run('DELETE from appeals WHERE id = ?', appealId); await Database.db.run('DELETE from appeals WHERE id = ?', appealId);
} }
+16
View File
@@ -172,4 +172,20 @@ export type Record = {
updated_at: string updated_at: string
updater_id: number updater_id: number
is_deleted: boolean is_deleted: boolean
}
export type PostFlag = {
id: number
post_id: number
creator_id: number
reason: string
is_resolved: boolean
created_at: string
updated_at: string
is_deletion: boolean
note: string | null
reason_name: string
needs_parent_id: boolean
needs_staff_reason: boolean
type: string
} }
+45 -26
View File
@@ -1,9 +1,11 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, Client, EmbedBuilder } from 'discord.js'; import { ActionRowBuilder, APIEmbedField, ButtonBuilder, ButtonStyle, Client, DiscordAPIError, EmbedBuilder, Message } from 'discord.js';
import { config } from '../config'; import { config } from '../config';
import { Database } from '../shared/Database'; import { Database } from '../shared/Database';
import { Appeal, AppealUpdate } from '../types'; import { Appeal, AppealUpdate, E621Post, PostFlag } from '../types';
import { getAuthor, getColor, getDescription, getFields } from './event-utils'; import { getAuthor, getColor, getDescription, getFields, getLinks } from './event-utils';
import { humanizeCapitalization } from './string-utils'; import { humanizeCapitalization } from './string-utils';
import { getE621Post, getE621PostFlag } from './e621-utils';
import { parseDTextToMarkdown } from '@clynamic/dmark';
export async function appealUpdateHandler(client: Client, update: string) { export async function appealUpdateHandler(client: Client, update: string) {
const data: AppealUpdate = JSON.parse(update); const data: AppealUpdate = JSON.parse(update);
@@ -26,13 +28,16 @@ async function postAppeal(client: Client, data: AppealUpdate) {
const appeal = data.appeal; const appeal = data.appeal;
const embed = await createEmbedFromAppeal(appeal); const flag = await getE621PostFlag(appeal.target_id);
const post = await getE621Post(flag!.post_id);
const row = await getButtons(appeal); const embed = await createEmbedFromAppeal(appeal, flag!, post!);
const row = await getButtons(appeal, flag!, post!);
const message = await channel.send({ embeds: [embed], components: row.components.length > 0 ? [row] : [] }); const message = await channel.send({ embeds: [embed], components: row.components.length > 0 ? [row] : [] });
await Database.putAppeal(appeal.id, message.id); await Database.putAppealOrUpdate(appeal.id, message.id);
} }
async function updateAppeal(client: Client, data: AppealUpdate) { async function updateAppeal(client: Client, data: AppealUpdate) {
@@ -48,16 +53,24 @@ async function updateAppeal(client: Client, data: AppealUpdate) {
if (!messageId) return postAppeal(client, data); if (!messageId) return postAppeal(client, data);
const message = await channel.messages.fetch(messageId); let message: Message | undefined;
const embed = await createEmbedFromAppeal(data.appeal);
if (!message || message.author.id != config.DISCORD_CLIENT_ID) { try {
const newMessage = await channel.send({ embeds: [embed] }); message = await channel.messages.fetch(messageId);
await Database.removeAppeal(data.appeal.id); } catch (e) {
await Database.putAppeal(data.appeal.id, newMessage.id); // Ignore unknown message errors
} else { if (!(e instanceof DiscordAPIError && e.code == 10008)) {
await message.edit({ embeds: [embed] }); throw e;
}
} }
if (!message || message.author.id != config.DISCORD_CLIENT_ID) return postAppeal(client, data);
const flag = await getE621PostFlag(data.appeal.target_id);
const post = await getE621Post(flag!.post_id);
const embed = await createEmbedFromAppeal(data.appeal, flag!, post!);
await message.edit({ embeds: [embed] });
} }
function getTitle(appeal: Appeal): string { function getTitle(appeal: Appeal): string {
@@ -75,30 +88,36 @@ function getURL(appeal: Appeal): string {
return `${config.E621_BASE_URL}/appeals/${appeal.id}`; return `${config.E621_BASE_URL}/appeals/${appeal.id}`;
} }
async function createEmbedFromAppeal(appeal: Appeal): Promise<EmbedBuilder> { async function getCustomFields(appeal: Appeal, flag: PostFlag, post: E621Post): Promise<APIEmbedField[]> {
return [
{
name: 'Deletion Reason',
value: parseDTextToMarkdown(await getLinks(flag.reason)).output,
inline: true
}
];
}
async function createEmbedFromAppeal(appeal: Appeal, flag: PostFlag, post: E621Post): Promise<EmbedBuilder> {
return new EmbedBuilder() return new EmbedBuilder()
.setTitle(getTitle(appeal)) .setTitle(getTitle(appeal))
.setURL(await getURL(appeal)) .setURL(await getURL(appeal))
.setDescription(await getDescription(appeal)) .setDescription(await getDescription(appeal))
.setAuthor(getAuthor(appeal)) .setAuthor(getAuthor(appeal))
.setColor(getColor(appeal)) .setColor(getColor(appeal))
.setFields(...getFields(appeal)) .setFields(...getFields(appeal), ...(await getCustomFields(appeal, flag, post)))
.setFooter({ text: `Appeal #${appeal.id}` }); .setFooter({ text: `Appeal #${appeal.id}` });
} }
async function getButtons(appeal: Appeal): Promise<ActionRowBuilder<ButtonBuilder>> { async function getButtons(appeal: Appeal, flag: PostFlag, post: E621Post): Promise<ActionRowBuilder<ButtonBuilder>> {
const row = new ActionRowBuilder<ButtonBuilder>(); const row = new ActionRowBuilder<ButtonBuilder>();
const primaryButton = new ButtonBuilder() const button = new ButtonBuilder()
.setStyle(ButtonStyle.Link); .setLabel('Open Post')
.setStyle(ButtonStyle.Link)
.setURL(`${config.E621_BASE_URL}/posts/${post.id}`);
if (appeal.category == 'flag') { row.addComponents(button);
primaryButton
.setLabel('Open Flag')
.setURL(`${config.E621_BASE_URL}/post_flags/${appeal.target_id}`);
row.addComponents(primaryButton);
}
return row; return row;
} }
-5
View File
@@ -1,5 +0,0 @@
import { formatMarkdown, parseDTextToAST } from '@clynamic/dmark';
export function dtextToMarkdown(dtext: string): string {
return formatMarkdown(parseDTextToAST(dtext)).output;
}
+7 -3
View File
@@ -1,5 +1,5 @@
import { config } from '../config'; import { config } from '../config';
import { E621Post, E621User, Record } from '../types'; import { E621Post, E621User, PostFlag, Record } from '../types';
const BLACKLISTED_TAGS: string[] = []; const BLACKLISTED_TAGS: string[] = [];
const BLACKLISTED_NONSAFE_TAGS: string[] = ['young']; const BLACKLISTED_NONSAFE_TAGS: string[] = ['young'];
@@ -35,11 +35,15 @@ export async function getE621User(idOrName: string | number): Promise<E621User |
} }
export async function getE621Post(id: string | number): Promise<E621Post | null> { export async function getE621Post(id: string | number): Promise<E621Post | null> {
return (await request(`/posts/${id}`))?.post as E621Post ?? null; return (await request(`/posts/${id}`, { v2: 'true' })) as E621Post ?? null;
} }
export async function getE621PostByMd5(md5: string): Promise<E621Post | null> { export async function getE621PostByMd5(md5: string): Promise<E621Post | null> {
return (await request('/posts', { md5 }))?.post as E621Post ?? null; return (await request('/posts', { md5, v2: 'true' })) as E621Post ?? null;
}
export async function getE621PostFlag(id: number): Promise<PostFlag | null> {
return await request(`/post_flags/${id}`) as PostFlag ?? null;
} }
export const enum PostAction { export const enum PostAction {
+4 -2
View File
@@ -2,7 +2,7 @@ import { APIEmbedField, EmbedAuthorOptions } from 'discord.js';
import { config } from '../config'; import { config } from '../config';
import { getE621Post, PostAction, spoilerOrBlacklist } from './e621-utils'; import { getE621Post, PostAction, spoilerOrBlacklist } from './e621-utils';
import { appealIDRegex, blipIDRegex, commentIDRegex, flagIDRegex, forumTopicIDRegex, poolIDRegex, postIDRegex, recordIDRegex, searchLinkRegex, setIDRegex, takedownIDRegex, ticketIDRegex, userIDRegex, wikiLinkRegex } from './message-matcher-regex'; import { appealIDRegex, blipIDRegex, commentIDRegex, flagIDRegex, forumTopicIDRegex, poolIDRegex, postIDRegex, recordIDRegex, searchLinkRegex, setIDRegex, takedownIDRegex, ticketIDRegex, userIDRegex, wikiLinkRegex } from './message-matcher-regex';
import { dtextToMarkdown } from './dtext-utils'; import { parseDTextToMarkdown } from '@clynamic/dmark';
// TODO: Condense this and the message event handler regex array. // TODO: Condense this and the message event handler regex array.
const linkReplacers = [ const linkReplacers = [
@@ -135,7 +135,9 @@ export async function getLinks(input: string, limit: number = Number.MAX_SAFE_IN
} }
export async function getDescription(data: { reason: string }): Promise<string> { export async function getDescription(data: { reason: string }): Promise<string> {
return dtextToMarkdown(data.reason.length <= MAX_DESCRIPTION_LENGTH ? await getLinks(data.reason) : await getLinks(data.reason, MAX_DESCRIPTION_LENGTH)); return parseDTextToMarkdown(data.reason.length <= MAX_DESCRIPTION_LENGTH ? await getLinks(data.reason) : await getLinks(data.reason, MAX_DESCRIPTION_LENGTH), {
baseUrl: 'https://e621.net'
}).output;
} }
export function getAuthor(data: { user_id: number, user: string }): EmbedAuthorOptions { export function getAuthor(data: { user_id: number, user: string }): EmbedAuthorOptions {
-1
View File
@@ -8,7 +8,6 @@ export * from './channel-utils';
export * from './commands'; export * from './commands';
export * from './debug-utils'; export * from './debug-utils';
export * from './discord-user-utils'; export * from './discord-user-utils';
export * from './dtext-utils';
export * from './e621-utils'; export * from './e621-utils';
export * from './embed-utils'; export * from './embed-utils';
export * from './event-log-utils'; export * from './event-log-utils';
+16 -10
View File
@@ -1,4 +1,4 @@
import { ActionRowBuilder, ButtonBuilder, ButtonStyle, Client, EmbedBuilder, SendableChannels } from 'discord.js'; import { ActionRowBuilder, ButtonBuilder, ButtonStyle, Client, DiscordAPIError, EmbedBuilder, Message, SendableChannels } from 'discord.js';
import { config } from '../config'; import { config } from '../config';
import { Database } from '../shared/Database'; import { Database } from '../shared/Database';
import { Ticket, TicketPhrase, TicketUpdate } from '../types'; import { Ticket, TicketPhrase, TicketUpdate } from '../types';
@@ -34,7 +34,7 @@ async function postTicket(client: Client, data: TicketUpdate) {
const message = await channel.send({ embeds: [embed], components: [row] }); const message = await channel.send({ embeds: [embed], components: [row] });
await Database.putTicket(ticket.id, message.id); await Database.putTicketOrUpdate(ticket.id, message.id);
sendTicketAlerts(ticket, channel); sendTicketAlerts(ticket, channel);
} }
@@ -52,16 +52,22 @@ async function updateTicket(client: Client, data: TicketUpdate) {
if (!messageId) return postTicket(client, data); if (!messageId) return postTicket(client, data);
const message = await channel.messages.fetch(messageId); let message: Message | undefined;
try {
message = await channel.messages.fetch(messageId);
} catch (e) {
// Ignore unknown message errors
if (!(e instanceof DiscordAPIError && e.code == 10008)) {
throw e;
}
}
if (!message || message.author.id != config.DISCORD_CLIENT_ID) return postTicket(client, data);
const embed = await createEmbedFromTicket(data.ticket); const embed = await createEmbedFromTicket(data.ticket);
if (!message || message.author.id != config.DISCORD_CLIENT_ID) { await message.edit({ embeds: [embed] });
const newMessage = await channel.send({ embeds: [embed] });
await Database.removeTicket(data.ticket.id);
await Database.putTicket(data.ticket.id, newMessage.id);
} else {
await message.edit({ embeds: [embed] });
}
} }
function getTitle(ticket: Ticket): string { function getTitle(ticket: Ticket): string {
+5 -2
View File
@@ -16,7 +16,10 @@
"ES2021.String" "ES2021.String"
] ]
}, },
"include": ["src"], "include": ["src"],
"exclude": ["node_modules"] "exclude": ["node_modules"],
"tsc-alias": {
"resolveFullPaths": true,
"verbose": false
}
} }