diff --git a/package.json b/package.json index 2097584..9317a49 100644 --- a/package.json +++ b/package.json @@ -9,12 +9,26 @@ "check": "tsc" }, "dependencies": { + "canvas": "^3.1.0", "discord.js": "^14.17.2", + "sharp": "git+ssh://git@github.com/lovell/sharp.git", "ts-node": "^10.9.2", "zod": "^3.24.2" }, "devDependencies": { "typescript": "^5.5.3" }, - "private": true + "private": true, + "pnpm": { + "ignoredBuiltDependencies": [ + "canvas" + ], + "onlyBuiltDependencies": [ + "canvas", + "sharp" + ], + "patchedDependencies": { + "sharp@0.34.0-rc.0": "patches/sharp@0.34.0-rc.0.patch" + } + } } diff --git a/patches/sharp@0.34.0-rc.0.patch b/patches/sharp@0.34.0-rc.0.patch new file mode 100644 index 0000000..689b135 --- /dev/null +++ b/patches/sharp@0.34.0-rc.0.patch @@ -0,0 +1,13 @@ +diff --git a/lib/sharp.js b/lib/sharp.js +index 78853e95fd55c3074352d7a7356c399b99170ba4..36001995f9e1acf4c381e0dabefcee131a18aade 100644 +--- a/lib/sharp.js ++++ b/lib/sharp.js +@@ -30,7 +30,7 @@ for (path of paths) { + } + + /* istanbul ignore next */ +-if (sharp && path.startsWith('@img/sharp-linux-x64') && !sharp._isUsingX64V2()) { ++if (sharp && path.startsWith('@img/sharp-linux-x64') && false) { + const err = new Error('Prebuilt binaries for linux-x64 require v2 microarchitecture'); + err.code = 'Unsupported CPU'; + errors.push(err); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 11d63c0..9e579bc 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,13 +4,24 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +patchedDependencies: + sharp@0.34.0-rc.0: + hash: aec393aef46aa4fa39e5c8d152bbe386c4b9df13f70cc0a46ee371547d7395dc + path: patches/sharp@0.34.0-rc.0.patch + importers: .: dependencies: + canvas: + specifier: ^3.1.0 + version: 3.1.0 discord.js: specifier: ^14.17.2 version: 14.17.2 + sharp: + specifier: git+ssh://git@github.com/lovell/sharp.git + version: https://codeload.github.com/lovell/sharp/tar.gz/03e1b19764719d1b031045420223e78160db9bd0(patch_hash=aec393aef46aa4fa39e5c8d152bbe386c4b9df13f70cc0a46ee371547d7395dc) ts-node: specifier: ^10.9.2 version: 10.9.2(@types/node@22.10.5)(typescript@5.7.2) @@ -56,6 +67,119 @@ packages: resolution: {integrity: sha512-QH5CAFe3wHDiedbO+EI3OOiyipwWd+Q6BdoFZUw/Wf2fw5Cv2fgU/9UEtJRmJa9RecI+TAhdGPadMaEIur5yJg==} engines: {node: '>=16.11.0'} + '@emnapi/runtime@1.3.1': + resolution: {integrity: sha512-kEBmG8KyqtxJZv+ygbEim+KCGtIq1fC22Ms3S4ziXmYKm8uyoLX0MHONVKwp+9opg390VaKRNt4a7A9NwmpNhw==} + + '@img/sharp-darwin-arm64@0.34.0-rc.0': + resolution: {integrity: sha512-qbkTsi4yItqb+bvi3JVbgIVPixk4sz7r1F5aw80vzK+q0yHj9lTFYkqnqWhCGNggp3MZfwx4Gqre5M+Y9ITwwQ==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm64] + os: [darwin] + + '@img/sharp-darwin-x64@0.34.0-rc.0': + resolution: {integrity: sha512-aOLXjFWhVcBUpDIWFAZ1AalJKXpm0d1vRQ5alAqTYFZgLwOk80LTEXWy32TQqRUQlHIiUBVq4Aw1KcwvFgPM7Q==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [darwin] + + '@img/sharp-libvips-darwin-arm64@1.1.0-rc4': + resolution: {integrity: sha512-AVPOee9ZyJ5MfS1Iuyx1M2VKHHKnL+kFFp1fWt3QqBWuTVs3JR8ApJOOdmY/Y8Z9sR1eQ3EHsCrzfKCcLxTMRg==} + cpu: [arm64] + os: [darwin] + + '@img/sharp-libvips-darwin-x64@1.1.0-rc4': + resolution: {integrity: sha512-m2etL2MOBqAp7e7fjJqktTQW13gSY+XQ1rXlQ+AzxviASMhQdpRxPeQgtX7lwnsUL+4S/blRrjh+gVL1LnlsgA==} + cpu: [x64] + os: [darwin] + + '@img/sharp-libvips-linux-arm64@1.1.0-rc4': + resolution: {integrity: sha512-27/wAovlMES4A0dFMRaACcoytVHtQc8QcptQwJBOZHF6IeGPsq6WN3RqDDRNs+T9O7WV+ivALLjCCDIHxXA3Zw==} + cpu: [arm64] + os: [linux] + + '@img/sharp-libvips-linux-arm@1.1.0-rc4.1': + resolution: {integrity: sha512-GvScbEYBFtNMXJuIjXtKCuod66NN52sS2MJEiNQZyEly5aoaJACYnjyszwBfGQTkuxx2Sr2Wv2vTJhtsomCBGA==} + cpu: [arm] + os: [linux] + + '@img/sharp-libvips-linux-ppc64@1.1.0-rc4': + resolution: {integrity: sha512-bXCe1kN7ZoC6f+aryXYpi+SEIGFmWxQxa1IQ8XBh3RgtsUiWF8/yfPtYyUHRIt4RXVNABEcpaSvHrtMqunTPQA==} + cpu: [ppc64] + os: [linux] + + '@img/sharp-libvips-linux-s390x@1.1.0-rc4': + resolution: {integrity: sha512-OpVPJ8XfmrwQ5txkzdCliT57IBrFBBF4EqwrLdq9SqeUtnyM2GlgQf+3TRTmnh3LT4HGC/13VgBmYgWXxTv8cw==} + cpu: [s390x] + os: [linux] + + '@img/sharp-libvips-linux-x64@1.1.0-rc4': + resolution: {integrity: sha512-Wo3OjH0RaQrhAnSiNv8IvunVSzg73n7WxzmxnwzyHW9pooDzDfF9CnRpIW6KD84Sj/LRLT+ZuaU5ro4b4tYv4A==} + cpu: [x64] + os: [linux] + + '@img/sharp-libvips-linuxmusl-arm64@1.1.0-rc4': + resolution: {integrity: sha512-cftYedmpewmg6STcGp63W09RAXVDQXZaAmlw7/8cMnH7q/XJKPmWVdQW3TWDNd7Ag7Z1ZF5zJ4C2N8+84eBX7g==} + cpu: [arm64] + os: [linux] + + '@img/sharp-libvips-linuxmusl-x64@1.1.0-rc4': + resolution: {integrity: sha512-wqfQrWDbwuPu5XWPNIizZ49q8jXFWlp4zBENG7JwzXEP+BIpT4aQbw92Oaep1bXZF7zXaQjowm6c+ifU5aVG2Q==} + cpu: [x64] + os: [linux] + + '@img/sharp-linux-arm64@0.34.0-rc.0': + resolution: {integrity: sha512-BGIQ198i7vRidGUw9vXCiq1cOeihCRaryZUKyk+nnC5NgjXi4MGGDUuMtIO9oWc0m82uxEAh1Anv2Gob7nL7Bw==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm64] + os: [linux] + + '@img/sharp-linux-arm@0.34.0-rc.0': + resolution: {integrity: sha512-zEyjTaR8L1NigTkuZ4+aOQKFhqJmaum/0B8y4KrJf4veRCDIWUWemMEMTG5y0U8unIsyhPi3HKXSqAHARvie4A==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm] + os: [linux] + + '@img/sharp-linux-s390x@0.34.0-rc.0': + resolution: {integrity: sha512-zjcm7vPxPqIfKE5XbSvwMYc7ZYA7GZmCW2+o/B5i5DhoomLrx4IlBjt7+L4WykMdQkrYkDaFmTRORoD6/Veh6g==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [s390x] + os: [linux] + + '@img/sharp-linux-x64@0.34.0-rc.0': + resolution: {integrity: sha512-XO+D78ZrbYYHiBaqXDkc+vHWlRAn1k03hVhkPxpLyEEAN7gHGfIFVBPlE2yZhbMloqEW41zfIpSY6Vg8SS1poQ==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [linux] + + '@img/sharp-linuxmusl-arm64@0.34.0-rc.0': + resolution: {integrity: sha512-CqYOm0aOg+6+Ep7Dbtl5/V9Ll8u5aGK/e6XLVSZLMsJ+Bfh02NnYVDJZhYZPh1QmvnqUJwCX8egIL4lpiMPuCw==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [arm64] + os: [linux] + + '@img/sharp-linuxmusl-x64@0.34.0-rc.0': + resolution: {integrity: sha512-DIbS0nAMAmKsLxCvtoQSFpMWbk4G460kb0axjL4M3oaRCEcXCPwa2gsgiVwoy6YYxCxBBDyzgQt4AggLEMpSXA==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [linux] + + '@img/sharp-wasm32@0.34.0-rc.0': + resolution: {integrity: sha512-8mUPtwQXmw5YbUJMZjIhtuF+MpX+8ib2aQ4f143y5EFi4yej3qzNw8yxWUaor3VxaZMJNwTgG23K75Hj0eymTw==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [wasm32] + + '@img/sharp-win32-ia32@0.34.0-rc.0': + resolution: {integrity: sha512-HvKmPPepuoJb7bzv8aRR13/WVN2YPhcgdb6R9w5z8i08Eijglb5gzB+z4/ajRvPjC6GCn121/XLtM59b5HzDQQ==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [ia32] + os: [win32] + + '@img/sharp-win32-x64@0.34.0-rc.0': + resolution: {integrity: sha512-4buOejyM4w+TsTHyYSXXxwPY4hsHmoZhJLlasF8/TiqeiSMr7rprJ/4PtCCaSfF+Y6HdhCDFBUpispDUxLky2g==} + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + cpu: [x64] + os: [win32] + '@jridgewell/resolve-uri@3.1.2': resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} @@ -112,9 +236,51 @@ packages: arg@4.1.3: resolution: {integrity: sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==} + base64-js@1.5.1: + resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + + bl@4.1.0: + resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} + + buffer@5.7.1: + resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} + + canvas@3.1.0: + resolution: {integrity: sha512-tTj3CqqukVJ9NgSahykNwtGda7V33VLObwrHfzT0vqJXu7J4d4C/7kQQW3fOEGDfZZoILPut5H00gOjyttPGyg==} + engines: {node: ^18.12.0 || >= 20.9.0} + + chownr@1.1.4: + resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} + + color-convert@2.0.1: + resolution: {integrity: sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==} + engines: {node: '>=7.0.0'} + + color-name@1.1.4: + resolution: {integrity: sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==} + + color-string@1.9.1: + resolution: {integrity: sha512-shrVawQFojnZv6xM40anx4CkoDP+fZsw/ZerEMsW/pyzsRbElpsL/DBVW7q3ExxwusdNXI3lXpuhEZkzs8p5Eg==} + + color@4.2.3: + resolution: {integrity: sha512-1rXeuUUiGGrykh+CeBdu5Ie7OJwinCgQY0bc7GCRxy5xVHy+moaqkpL/jqQq0MtQOeYcrqEz4abc5f0KtU7W4A==} + engines: {node: '>=12.5.0'} + create-require@1.1.1: resolution: {integrity: sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ==} + decompress-response@6.0.0: + resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==} + engines: {node: '>=10'} + + deep-extend@0.6.0: + resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} + engines: {node: '>=4.0.0'} + + detect-libc@2.0.3: + resolution: {integrity: sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==} + engines: {node: '>=8'} + diff@4.0.2: resolution: {integrity: sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A==} engines: {node: '>=0.3.1'} @@ -126,9 +292,34 @@ packages: resolution: {integrity: sha512-mrH6ziLVtNtId4bV4bsaUt5jE6NUaiHMPqO5VsSw1VVhFnjFi9duD8ctlo90/6cUH+8uyKBkoq9mSJ35SuuZ7Q==} engines: {node: '>=18'} + end-of-stream@1.4.4: + resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==} + + expand-template@2.0.3: + resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} + engines: {node: '>=6'} + fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + fs-constants@1.0.0: + resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} + + github-from-package@0.0.0: + resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==} + + ieee754@1.2.1: + resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + + inherits@2.0.4: + resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} + + ini@1.3.8: + resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} + + is-arrayish@0.3.2: + resolution: {integrity: sha512-eVRqCvVlZbuw3GrM63ovNSNAeA1K16kaR/LRY/92w0zxQ5/1YzwblUX652i4Xs9RwAGjW9d9y6X88t8OaAJfWQ==} + lodash.snakecase@4.1.1: resolution: {integrity: sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==} @@ -141,6 +332,81 @@ packages: make-error@1.3.6: resolution: {integrity: sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==} + mimic-response@3.1.0: + resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==} + engines: {node: '>=10'} + + minimist@1.2.8: + resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} + + mkdirp-classic@0.5.3: + resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} + + napi-build-utils@2.0.0: + resolution: {integrity: sha512-GEbrYkbfF7MoNaoh2iGG84Mnf/WZfB0GdGEsM8wz7Expx/LlWf5U8t9nvJKXSp3qr5IsEbK04cBGhol/KwOsWA==} + + node-abi@3.74.0: + resolution: {integrity: sha512-c5XK0MjkGBrQPGYG24GBADZud0NCbznxNx0ZkS+ebUTrmV1qTDxPxSL8zEAPURXSbLRWVexxmP4986BziahL5w==} + engines: {node: '>=10'} + + node-addon-api@7.1.1: + resolution: {integrity: sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==} + + once@1.4.0: + resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} + + prebuild-install@7.1.3: + resolution: {integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==} + engines: {node: '>=10'} + hasBin: true + + pump@3.0.2: + resolution: {integrity: sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==} + + rc@1.2.8: + resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} + hasBin: true + + readable-stream@3.6.2: + resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} + engines: {node: '>= 6'} + + safe-buffer@5.2.1: + resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} + + semver@7.7.1: + resolution: {integrity: sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==} + engines: {node: '>=10'} + hasBin: true + + sharp@https://codeload.github.com/lovell/sharp/tar.gz/03e1b19764719d1b031045420223e78160db9bd0: + resolution: {tarball: https://codeload.github.com/lovell/sharp/tar.gz/03e1b19764719d1b031045420223e78160db9bd0} + version: 0.34.0-rc.0 + engines: {node: ^18.17.0 || ^20.3.0 || >=21.0.0} + + simple-concat@1.0.1: + resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==} + + simple-get@4.0.1: + resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==} + + simple-swizzle@0.2.2: + resolution: {integrity: sha512-JA//kQgZtbuY83m+xT+tXJkmJncGMTFT+C+g2h2R9uxkYIrE2yy9sgmcLhCnw57/WSD+Eh3J97FPEDFnbXnDUg==} + + string_decoder@1.3.0: + resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} + + strip-json-comments@2.0.1: + resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==} + engines: {node: '>=0.10.0'} + + tar-fs@2.1.2: + resolution: {integrity: sha512-EsaAXwxmx8UB7FRKqeozqEPop69DXcmYwTQwXvyAPF352HJsPdkVhvTaDPYqfNgruveJIJy3TA2l+2zj8LJIJA==} + + tar-stream@2.2.0: + resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} + engines: {node: '>=6'} + ts-mixer@6.0.4: resolution: {integrity: sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==} @@ -161,6 +427,9 @@ packages: tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + tunnel-agent@0.6.0: + resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==} + typescript@5.7.2: resolution: {integrity: sha512-i5t66RHxDvVN40HfDd1PsEThGNnlMCMT3jMUuoh9/0TaqWevNontacunWyN02LA9/fIbEWlcHZcgTKb9QoaLfg==} engines: {node: '>=14.17'} @@ -173,9 +442,15 @@ packages: resolution: {integrity: sha512-U8uCCl2x9TK3WANvmBavymRzxbfFYG+tAu+fgx3zxQy3qdagQqBLwJVrdyO1TBfUXvfKveMKJZhpvUYoOjM+4g==} engines: {node: '>=18.17'} + util-deprecate@1.0.2: + resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + v8-compile-cache-lib@3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} + wrappy@1.0.2: + resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + ws@8.18.0: resolution: {integrity: sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==} engines: {node: '>=10.0.0'} @@ -248,6 +523,89 @@ snapshots: - bufferutil - utf-8-validate + '@emnapi/runtime@1.3.1': + dependencies: + tslib: 2.8.1 + optional: true + + '@img/sharp-darwin-arm64@0.34.0-rc.0': + optionalDependencies: + '@img/sharp-libvips-darwin-arm64': 1.1.0-rc4 + optional: true + + '@img/sharp-darwin-x64@0.34.0-rc.0': + optionalDependencies: + '@img/sharp-libvips-darwin-x64': 1.1.0-rc4 + optional: true + + '@img/sharp-libvips-darwin-arm64@1.1.0-rc4': + optional: true + + '@img/sharp-libvips-darwin-x64@1.1.0-rc4': + optional: true + + '@img/sharp-libvips-linux-arm64@1.1.0-rc4': + optional: true + + '@img/sharp-libvips-linux-arm@1.1.0-rc4.1': + optional: true + + '@img/sharp-libvips-linux-ppc64@1.1.0-rc4': + optional: true + + '@img/sharp-libvips-linux-s390x@1.1.0-rc4': + optional: true + + '@img/sharp-libvips-linux-x64@1.1.0-rc4': + optional: true + + '@img/sharp-libvips-linuxmusl-arm64@1.1.0-rc4': + optional: true + + '@img/sharp-libvips-linuxmusl-x64@1.1.0-rc4': + optional: true + + '@img/sharp-linux-arm64@0.34.0-rc.0': + optionalDependencies: + '@img/sharp-libvips-linux-arm64': 1.1.0-rc4 + optional: true + + '@img/sharp-linux-arm@0.34.0-rc.0': + optionalDependencies: + '@img/sharp-libvips-linux-arm': 1.1.0-rc4.1 + optional: true + + '@img/sharp-linux-s390x@0.34.0-rc.0': + optionalDependencies: + '@img/sharp-libvips-linux-s390x': 1.1.0-rc4 + optional: true + + '@img/sharp-linux-x64@0.34.0-rc.0': + optionalDependencies: + '@img/sharp-libvips-linux-x64': 1.1.0-rc4 + optional: true + + '@img/sharp-linuxmusl-arm64@0.34.0-rc.0': + optionalDependencies: + '@img/sharp-libvips-linuxmusl-arm64': 1.1.0-rc4 + optional: true + + '@img/sharp-linuxmusl-x64@0.34.0-rc.0': + optionalDependencies: + '@img/sharp-libvips-linuxmusl-x64': 1.1.0-rc4 + optional: true + + '@img/sharp-wasm32@0.34.0-rc.0': + dependencies: + '@emnapi/runtime': 1.3.1 + optional: true + + '@img/sharp-win32-ia32@0.34.0-rc.0': + optional: true + + '@img/sharp-win32-x64@0.34.0-rc.0': + optional: true + '@jridgewell/resolve-uri@3.1.2': {} '@jridgewell/sourcemap-codec@1.5.0': {} @@ -292,8 +650,52 @@ snapshots: arg@4.1.3: {} + base64-js@1.5.1: {} + + bl@4.1.0: + dependencies: + buffer: 5.7.1 + inherits: 2.0.4 + readable-stream: 3.6.2 + + buffer@5.7.1: + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + + canvas@3.1.0: + dependencies: + node-addon-api: 7.1.1 + prebuild-install: 7.1.3 + + chownr@1.1.4: {} + + color-convert@2.0.1: + dependencies: + color-name: 1.1.4 + + color-name@1.1.4: {} + + color-string@1.9.1: + dependencies: + color-name: 1.1.4 + simple-swizzle: 0.2.2 + + color@4.2.3: + dependencies: + color-convert: 2.0.1 + color-string: 1.9.1 + create-require@1.1.1: {} + decompress-response@6.0.0: + dependencies: + mimic-response: 3.1.0 + + deep-extend@0.6.0: {} + + detect-libc@2.0.3: {} + diff@4.0.2: {} discord-api-types@0.37.115: {} @@ -316,8 +718,26 @@ snapshots: - bufferutil - utf-8-validate + end-of-stream@1.4.4: + dependencies: + once: 1.4.0 + + expand-template@2.0.3: {} + fast-deep-equal@3.1.3: {} + fs-constants@1.0.0: {} + + github-from-package@0.0.0: {} + + ieee754@1.2.1: {} + + inherits@2.0.4: {} + + ini@1.3.8: {} + + is-arrayish@0.3.2: {} + lodash.snakecase@4.1.1: {} lodash@4.17.21: {} @@ -326,6 +746,121 @@ snapshots: make-error@1.3.6: {} + mimic-response@3.1.0: {} + + minimist@1.2.8: {} + + mkdirp-classic@0.5.3: {} + + napi-build-utils@2.0.0: {} + + node-abi@3.74.0: + dependencies: + semver: 7.7.1 + + node-addon-api@7.1.1: {} + + once@1.4.0: + dependencies: + wrappy: 1.0.2 + + prebuild-install@7.1.3: + dependencies: + detect-libc: 2.0.3 + expand-template: 2.0.3 + github-from-package: 0.0.0 + minimist: 1.2.8 + mkdirp-classic: 0.5.3 + napi-build-utils: 2.0.0 + node-abi: 3.74.0 + pump: 3.0.2 + rc: 1.2.8 + simple-get: 4.0.1 + tar-fs: 2.1.2 + tunnel-agent: 0.6.0 + + pump@3.0.2: + dependencies: + end-of-stream: 1.4.4 + once: 1.4.0 + + rc@1.2.8: + dependencies: + deep-extend: 0.6.0 + ini: 1.3.8 + minimist: 1.2.8 + strip-json-comments: 2.0.1 + + readable-stream@3.6.2: + dependencies: + inherits: 2.0.4 + string_decoder: 1.3.0 + util-deprecate: 1.0.2 + + safe-buffer@5.2.1: {} + + semver@7.7.1: {} + + sharp@https://codeload.github.com/lovell/sharp/tar.gz/03e1b19764719d1b031045420223e78160db9bd0(patch_hash=aec393aef46aa4fa39e5c8d152bbe386c4b9df13f70cc0a46ee371547d7395dc): + dependencies: + color: 4.2.3 + detect-libc: 2.0.3 + semver: 7.7.1 + optionalDependencies: + '@img/sharp-darwin-arm64': 0.34.0-rc.0 + '@img/sharp-darwin-x64': 0.34.0-rc.0 + '@img/sharp-libvips-darwin-arm64': 1.1.0-rc4 + '@img/sharp-libvips-darwin-x64': 1.1.0-rc4 + '@img/sharp-libvips-linux-arm': 1.1.0-rc4.1 + '@img/sharp-libvips-linux-arm64': 1.1.0-rc4 + '@img/sharp-libvips-linux-ppc64': 1.1.0-rc4 + '@img/sharp-libvips-linux-s390x': 1.1.0-rc4 + '@img/sharp-libvips-linux-x64': 1.1.0-rc4 + '@img/sharp-libvips-linuxmusl-arm64': 1.1.0-rc4 + '@img/sharp-libvips-linuxmusl-x64': 1.1.0-rc4 + '@img/sharp-linux-arm': 0.34.0-rc.0 + '@img/sharp-linux-arm64': 0.34.0-rc.0 + '@img/sharp-linux-s390x': 0.34.0-rc.0 + '@img/sharp-linux-x64': 0.34.0-rc.0 + '@img/sharp-linuxmusl-arm64': 0.34.0-rc.0 + '@img/sharp-linuxmusl-x64': 0.34.0-rc.0 + '@img/sharp-wasm32': 0.34.0-rc.0 + '@img/sharp-win32-ia32': 0.34.0-rc.0 + '@img/sharp-win32-x64': 0.34.0-rc.0 + + simple-concat@1.0.1: {} + + simple-get@4.0.1: + dependencies: + decompress-response: 6.0.0 + once: 1.4.0 + simple-concat: 1.0.1 + + simple-swizzle@0.2.2: + dependencies: + is-arrayish: 0.3.2 + + string_decoder@1.3.0: + dependencies: + safe-buffer: 5.2.1 + + strip-json-comments@2.0.1: {} + + tar-fs@2.1.2: + dependencies: + chownr: 1.1.4 + mkdirp-classic: 0.5.3 + pump: 3.0.2 + tar-stream: 2.2.0 + + tar-stream@2.2.0: + dependencies: + bl: 4.1.0 + end-of-stream: 1.4.4 + fs-constants: 1.0.0 + inherits: 2.0.4 + readable-stream: 3.6.2 + ts-mixer@6.0.4: {} ts-node@10.9.2(@types/node@22.10.5)(typescript@5.7.2): @@ -348,14 +883,22 @@ snapshots: tslib@2.8.1: {} + tunnel-agent@0.6.0: + dependencies: + safe-buffer: 5.2.1 + typescript@5.7.2: {} undici-types@6.20.0: {} undici@6.19.8: {} + util-deprecate@1.0.2: {} + v8-compile-cache-lib@3.0.1: {} + wrappy@1.0.2: {} + ws@8.18.0: {} yn@3.1.1: {} diff --git a/src/commands/pat.ts b/src/commands/pat.ts new file mode 100644 index 0000000..990ef32 --- /dev/null +++ b/src/commands/pat.ts @@ -0,0 +1,73 @@ + +import { Command } from "../command.ts"; +import { + ApplicationIntegrationType, + Attachment, + AttachmentBuilder, + ChatInputCommandInteraction, + InteractionContextType, + SlashCommandBuilder +} from "discord.js"; +import { Config } from "../config.ts"; +import sharp, { SharpInput } from "sharp"; +import * as path from 'path'; +import { Canvas, loadImage } from "canvas"; +import { readdir, readFile } from "fs/promises"; + +const patpatGifPath = path.join('src/commands/', 'patpatframes') + +export default class PingCommand extends Command { + + async run(interaction: ChatInputCommandInteraction, config: Config) { + const user = interaction.options.getUser('user', true) + const avatarResponse = await fetch(user.avatarURL({})!) + const avatarBuf = Buffer.from(await avatarResponse.arrayBuffer()) + const frames: SharpInput[] = [] + const frame_avatar_positions = [ + [32, 102, 73, 65], + [32, 112, 73, 47], + ] as const + + let pos = 0 + for (const framePath of await readdir(patpatGifPath)) { + if (!framePath.endsWith(".png")) continue + const filePath = path.join(patpatGifPath, framePath) + const patImage = await loadImage(filePath); + const composite = new Canvas(patImage.width, patImage.height) + const context = composite.getContext('2d'); + const [x, y, w, h] = frame_avatar_positions[pos++] + const squishedAvatar = await loadImage(await sharp(avatarBuf).resize(w, h, { + fit: 'fill' + }).png().toBuffer()) + context.drawImage(squishedAvatar, x, y) + context.drawImage(patImage, 0, 0) + frames.push(composite.toBuffer('image/png')) + } + const webP = await sharp( + frames, + { join: { animated: true } } + ).webp({ delay: new Array(pos).fill(200), loop: 0 }).toBuffer(); + await interaction.reply({ + content: `Patting ${user.displayName}`, + files: [ + new AttachmentBuilder(webP) + .setName('softcorepattingaction.webp') + .setDescription(`the ${user.displayName} is being gently patted`), + ] + }); + } + + slashCommand = new SlashCommandBuilder() + .setName("pat") + .setDescription("Pats someone!").setIntegrationTypes([ + ApplicationIntegrationType.UserInstall + ]) + .addUserOption(builder => builder.setName("user") + .setDescription("The one to plap") + .setRequired(true)) + .setContexts([ + InteractionContextType.BotDM, + InteractionContextType.Guild, + InteractionContextType.PrivateChannel + ]); +} diff --git a/src/commands/patpatframes/patpat0.png b/src/commands/patpatframes/patpat0.png new file mode 100644 index 0000000..069d9cf Binary files /dev/null and b/src/commands/patpatframes/patpat0.png differ diff --git a/src/commands/patpatframes/patpat1.png b/src/commands/patpatframes/patpat1.png new file mode 100644 index 0000000..54a1d6d Binary files /dev/null and b/src/commands/patpatframes/patpat1.png differ diff --git a/src/commands/patpatframes/patpatempty.gif b/src/commands/patpatframes/patpatempty.gif new file mode 100644 index 0000000..6f115a8 Binary files /dev/null and b/src/commands/patpatframes/patpatempty.gif differ diff --git a/src/index.ts b/src/index.ts index fbd9de0..dda2429 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,6 +24,7 @@ const commands: Command[] = [] const commandDir = path.join(__dirname, "commands"); for (const file of fs.readdirSync(commandDir)) { + if (!file.endsWith('.ts')) continue let command = await import(path.join(commandDir, file)); commands.push(new command.default()) }