From 2dec2204d1df4ef9a6c3c91332af87090a758ff2 Mon Sep 17 00:00:00 2001 From: Tyler J Cvetan Date: Thu, 31 Oct 2024 19:37:55 +0000 Subject: [PATCH] feat: upgrading discordjs to v14 --- package-lock.json | 423 +++++++++++------- packages/bot/package.json | 10 +- .../discord/commands/create-character.ts | 11 - .../discord/commands/create-chronicle.ts | 36 +- .../commands/create-player-character.ts | 15 - .../src/framework/discord/commands/help.ts | 30 -- .../src/framework/discord/commands/index.ts | 12 +- .../src/framework/discord/commands/roll.ts | 14 - .../discord/commands/update-character.ts | 17 - .../src/framework/discord/configurations.ts | 16 +- .../src/framework/discord/deploy-commands.ts | 27 ++ packages/bot/src/framework/discord/index.ts | 84 ++-- .../framework/discord/messages/character.ts | 68 --- .../framework/discord/messages/chronicle.ts | 34 +- packages/bot/src/framework/discord/types.ts | 21 +- packages/bot/src/index.ts | 2 +- 16 files changed, 391 insertions(+), 429 deletions(-) delete mode 100644 packages/bot/src/framework/discord/commands/create-character.ts delete mode 100644 packages/bot/src/framework/discord/commands/create-player-character.ts delete mode 100644 packages/bot/src/framework/discord/commands/help.ts delete mode 100644 packages/bot/src/framework/discord/commands/roll.ts delete mode 100644 packages/bot/src/framework/discord/commands/update-character.ts create mode 100644 packages/bot/src/framework/discord/deploy-commands.ts delete mode 100644 packages/bot/src/framework/discord/messages/character.ts diff --git a/package-lock.json b/package-lock.json index c1af69b..2a72336 100644 --- a/package-lock.json +++ b/package-lock.json @@ -611,28 +611,157 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "node_modules/@discordjs/builders": { + "version": "1.9.0", + "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.9.0.tgz", + "integrity": "sha512-0zx8DePNVvQibh5ly5kCEei5wtPBIUbSoE9n+91Rlladz4tgtFbJ36PZMxxZrTEOQ7AHMZ/b0crT/0fCy6FTKg==", + "license": "Apache-2.0", + "dependencies": { + "@discordjs/formatters": "^0.5.0", + "@discordjs/util": "^1.1.1", + "@sapphire/shapeshift": "^4.0.0", + "discord-api-types": "0.37.97", + "fast-deep-equal": "^3.1.3", + "ts-mixer": "^6.0.4", + "tslib": "^2.6.3" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" + } + }, + "node_modules/@discordjs/builders/node_modules/discord-api-types": { + "version": "0.37.97", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.97.tgz", + "integrity": "sha512-No1BXPcVkyVD4ZVmbNgDKaBoqgeQ+FJpzZ8wqHkfmBnTZig1FcH3iPPersiK1TUIAzgClh2IvOuVUYfcWLQAOA==", + "license": "MIT" + }, "node_modules/@discordjs/collection": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.1.6.tgz", - "integrity": "sha512-utRNxnd9kSS2qhyivo9lMlt5qgAUasH2gb7BEOn6p0efFh24gjGomHzWKMAPn2hEReOPQZCJaRKoURwRotKucQ==", - "deprecated": "no longer supported", - "license": "Apache-2.0" + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.5.3.tgz", + "integrity": "sha512-SVb428OMd3WO1paV3rm6tSjM4wC+Kecaa1EUGX7vc6/fddvw/6lg90z4QtCqm21zvVe92vMMDt9+DkIvjXImQQ==", + "license": "Apache-2.0", + "engines": { + "node": ">=16.11.0" + } }, - "node_modules/@discordjs/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/@discordjs/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-ZfFsbgEXW71Rw/6EtBdrP5VxBJy4dthyC0tpQKGKmYFImlmmrykO14Za+BiIVduwjte0jXEBlhSKf0MWbFp9Eg==", - "deprecated": "Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.", - "license": "MIT", + "node_modules/@discordjs/formatters": { + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.5.0.tgz", + "integrity": "sha512-98b3i+Y19RFq1Xke4NkVY46x8KjJQjldHUuEbCqMvp1F5Iq9HgnGpu91jOi/Ufazhty32eRsKnnzS8n4c+L93g==", + "license": "Apache-2.0", "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" + "discord-api-types": "0.37.97" }, "engines": { - "node": ">= 6" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" } }, + "node_modules/@discordjs/formatters/node_modules/discord-api-types": { + "version": "0.37.97", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.97.tgz", + "integrity": "sha512-No1BXPcVkyVD4ZVmbNgDKaBoqgeQ+FJpzZ8wqHkfmBnTZig1FcH3iPPersiK1TUIAzgClh2IvOuVUYfcWLQAOA==", + "license": "MIT" + }, + "node_modules/@discordjs/rest": { + "version": "2.4.0", + "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-2.4.0.tgz", + "integrity": "sha512-Xb2irDqNcq+O8F0/k/NaDp7+t091p+acb51iA4bCKfIn+WFWd6HrNvcsSbMMxIR9NjcMZS6NReTKygqiQN+ntw==", + "license": "Apache-2.0", + "dependencies": { + "@discordjs/collection": "^2.1.1", + "@discordjs/util": "^1.1.1", + "@sapphire/async-queue": "^1.5.3", + "@sapphire/snowflake": "^3.5.3", + "@vladfrangu/async_event_emitter": "^2.4.6", + "discord-api-types": "0.37.97", + "magic-bytes.js": "^1.10.0", + "tslib": "^2.6.3", + "undici": "6.19.8" + }, + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" + } + }, + "node_modules/@discordjs/rest/node_modules/@discordjs/collection": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz", + "integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==", + "license": "Apache-2.0", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" + } + }, + "node_modules/@discordjs/rest/node_modules/discord-api-types": { + "version": "0.37.97", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.97.tgz", + "integrity": "sha512-No1BXPcVkyVD4ZVmbNgDKaBoqgeQ+FJpzZ8wqHkfmBnTZig1FcH3iPPersiK1TUIAzgClh2IvOuVUYfcWLQAOA==", + "license": "MIT" + }, + "node_modules/@discordjs/util": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@discordjs/util/-/util-1.1.1.tgz", + "integrity": "sha512-eddz6UnOBEB1oITPinyrB2Pttej49M9FZQY8NxgEvc3tq6ZICZ19m70RsmzRdDHk80O9NoYN/25AqJl8vPVf/g==", + "license": "Apache-2.0", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" + } + }, + "node_modules/@discordjs/ws": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@discordjs/ws/-/ws-1.1.1.tgz", + "integrity": "sha512-PZ+vLpxGCRtmr2RMkqh8Zp+BenUaJqlS6xhgWKEZcgC/vfHLEzpHtKkB0sl3nZWpwtcKk6YWy+pU3okL2I97FA==", + "license": "Apache-2.0", + "dependencies": { + "@discordjs/collection": "^2.1.0", + "@discordjs/rest": "^2.3.0", + "@discordjs/util": "^1.1.0", + "@sapphire/async-queue": "^1.5.2", + "@types/ws": "^8.5.10", + "@vladfrangu/async_event_emitter": "^2.2.4", + "discord-api-types": "0.37.83", + "tslib": "^2.6.2", + "ws": "^8.16.0" + }, + "engines": { + "node": ">=16.11.0" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" + } + }, + "node_modules/@discordjs/ws/node_modules/@discordjs/collection": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-2.1.1.tgz", + "integrity": "sha512-LiSusze9Tc7qF03sLCujF5iZp7K+vRNEDBZ86FT9aQAv3vxMLihUvKvpsCWiQ2DJq1tVckopKm1rxomgNUc9hg==", + "license": "Apache-2.0", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" + } + }, + "node_modules/@discordjs/ws/node_modules/discord-api-types": { + "version": "0.37.83", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.83.tgz", + "integrity": "sha512-urGGYeWtWNYMKnYlZnOnDHm8fVRffQs3U0SpE8RHeiuLKb/u92APS8HoQnPTFbnXmY1vVnXjXO4dOxcAn3J+DA==", + "license": "MIT" + }, "node_modules/@discoveryjs/json-ext": { "version": "0.5.7", "resolved": "https://registry.npmjs.org/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz", @@ -2999,6 +3128,39 @@ ], "peer": true }, + "node_modules/@sapphire/async-queue": { + "version": "1.5.3", + "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.5.3.tgz", + "integrity": "sha512-x7zadcfJGxFka1Q3f8gCts1F0xMwCKbZweM85xECGI0hBTeIZJGGCrHgLggihBoprlQ/hBmDR5LKfIPqnmHM3w==", + "license": "MIT", + "engines": { + "node": ">=v14.0.0", + "npm": ">=7.0.0" + } + }, + "node_modules/@sapphire/shapeshift": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-4.0.0.tgz", + "integrity": "sha512-d9dUmWVA7MMiKobL3VpLF8P2aeanRTu6ypG2OIaEv/ZHH/SUQ2iHOVyi5wAPjQ+HmnMuL0whK9ez8I/raWbtIg==", + "license": "MIT", + "dependencies": { + "fast-deep-equal": "^3.1.3", + "lodash": "^4.17.21" + }, + "engines": { + "node": ">=v16" + } + }, + "node_modules/@sapphire/snowflake": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.5.3.tgz", + "integrity": "sha512-jjmJywLAFoWeBi1W7994zZyiNWPIiqRRNAmSERxyg93xRGzNYvGjlZ0gR6x0F4gPRi2+0O6S71kOZYyr3cxaIQ==", + "license": "MIT", + "engines": { + "node": ">=v14.0.0", + "npm": ">=7.0.0" + } + }, "node_modules/@sec-ant/readable-stream": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/@sec-ant/readable-stream/-/readable-stream-0.4.1.tgz", @@ -4017,7 +4179,6 @@ "version": "22.8.2", "resolved": "https://registry.npmjs.org/@types/node/-/node-22.8.2.tgz", "integrity": "sha512-NzaRNFV+FZkvK/KLCsNdTvID0SThyrs5SHB6tsD/lajr22FGC73N2QeDPM2wHtVde8mgcXuSsHQkH5cX1pbPLw==", - "dev": true, "license": "MIT", "dependencies": { "undici-types": "~6.19.8" @@ -4109,6 +4270,15 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/ws": { + "version": "8.5.12", + "resolved": "https://registry.npmjs.org/@types/ws/-/ws-8.5.12.tgz", + "integrity": "sha512-3tPRkv1EtkDpzlgyKyI8pGsGZAGPEaXeu0DOj5DI25Ja91bdAYddYHbADRYVrZMRbfW+1l5YwXVDKohDJNQxkQ==", + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/yargs": { "version": "17.0.33", "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-17.0.33.tgz", @@ -4388,6 +4558,16 @@ "vite": "^4.2.0 || ^5.0.0" } }, + "node_modules/@vladfrangu/async_event_emitter": { + "version": "2.4.6", + "resolved": "https://registry.npmjs.org/@vladfrangu/async_event_emitter/-/async_event_emitter-2.4.6.tgz", + "integrity": "sha512-RaI5qZo6D2CVS6sTHFKg1v5Ohq/+Bo2LZ5gzUEwZ/WkHhwtGTCB/sVLw8ijOkAUxasZ+WshN/Rzj4ywsABJ5ZA==", + "license": "MIT", + "engines": { + "node": ">=v14.0.0", + "npm": ">=7.0.0" + } + }, "node_modules/@webassemblyjs/ast": { "version": "1.12.1", "resolved": "https://registry.npmjs.org/@webassemblyjs/ast/-/ast-1.12.1.tgz", @@ -4602,18 +4782,6 @@ "dev": true, "license": "Apache-2.0" }, - "node_modules/abort-controller": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", - "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", - "license": "MIT", - "dependencies": { - "event-target-shim": "^5.0.0" - }, - "engines": { - "node": ">=6.5" - } - }, "node_modules/acorn": { "version": "8.14.0", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.14.0.tgz", @@ -4875,12 +5043,6 @@ "node": ">=0.10.0" } }, - "node_modules/asynckit": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "license": "MIT" - }, "node_modules/babel-jest": { "version": "29.7.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.7.0.tgz", @@ -6133,18 +6295,6 @@ "node": ">=0.1.90" } }, - "node_modules/combined-stream": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "license": "MIT", - "dependencies": { - "delayed-stream": "~1.0.0" - }, - "engines": { - "node": ">= 0.8" - } - }, "node_modules/commander": { "version": "12.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-12.1.0.tgz", @@ -6662,15 +6812,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/delayed-stream": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "license": "MIT", - "engines": { - "node": ">=0.4.0" - } - }, "node_modules/detect-indent": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/detect-indent/-/detect-indent-7.0.1.tgz", @@ -6727,24 +6868,36 @@ "node": ">=8" } }, + "node_modules/discord-api-types": { + "version": "0.37.100", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.100.tgz", + "integrity": "sha512-a8zvUI0GYYwDtScfRd/TtaNBDTXwP5DiDVX7K5OmE+DRT57gBqKnwtOC5Ol8z0mRW8KQfETIgiB8U0YZ9NXiCA==", + "license": "MIT" + }, "node_modules/discord.js": { - "version": "12.5.3", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-12.5.3.tgz", - "integrity": "sha512-D3nkOa/pCkNyn6jLZnAiJApw2N9XrIsXUAdThf01i7yrEuqUmDGc7/CexVWwEcgbQR97XQ+mcnqJpmJ/92B4Aw==", - "deprecated": "no longer supported", + "version": "14.16.3", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.16.3.tgz", + "integrity": "sha512-EPCWE9OkA9DnFFNrO7Kl1WHHDYFXu3CNVFJg63bfU7hVtjZGyhShwZtSBImINQRWxWP2tgo2XI+QhdXx28r0aA==", "license": "Apache-2.0", "dependencies": { - "@discordjs/collection": "^0.1.6", - "@discordjs/form-data": "^3.0.1", - "abort-controller": "^3.0.0", - "node-fetch": "^2.6.1", - "prism-media": "^1.2.9", - "setimmediate": "^1.0.5", - "tweetnacl": "^1.0.3", - "ws": "^7.4.4" + "@discordjs/builders": "^1.9.0", + "@discordjs/collection": "1.5.3", + "@discordjs/formatters": "^0.5.0", + "@discordjs/rest": "^2.4.0", + "@discordjs/util": "^1.1.1", + "@discordjs/ws": "1.1.1", + "@sapphire/snowflake": "3.5.3", + "discord-api-types": "0.37.100", + "fast-deep-equal": "3.1.3", + "lodash.snakecase": "4.1.1", + "tslib": "^2.6.3", + "undici": "6.19.8" }, "engines": { - "node": ">=12.0.0" + "node": ">=18" + }, + "funding": { + "url": "https://github.com/discordjs/discord.js?sponsor" } }, "node_modules/dom-converter": { @@ -7265,15 +7418,6 @@ "node": ">=0.10.0" } }, - "node_modules/event-target-shim": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", - "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", - "license": "MIT", - "engines": { - "node": ">=6" - } - }, "node_modules/eventemitter3": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-5.0.1.tgz", @@ -7385,7 +7529,6 @@ "version": "3.1.3", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz", "integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==", - "dev": true, "license": "MIT" }, "node_modules/fast-glob": { @@ -10278,7 +10421,6 @@ "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", - "dev": true, "license": "MIT" }, "node_modules/lodash-es": { @@ -10323,6 +10465,12 @@ "dev": true, "license": "MIT" }, + "node_modules/lodash.snakecase": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.snakecase/-/lodash.snakecase-4.1.1.tgz", + "integrity": "sha512-QZ1d4xoBHYUeuouhEq3lk3Uq7ldgyFXGBhg04+oRLnIz8o9T65Eh+8YdroUwn846zchkA9yDsDl5CVVaV2nqYw==", + "license": "MIT" + }, "node_modules/lodash.uniqby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.uniqby/-/lodash.uniqby-4.7.0.tgz", @@ -10438,6 +10586,12 @@ "yallist": "^3.0.2" } }, + "node_modules/magic-bytes.js": { + "version": "1.10.0", + "resolved": "https://registry.npmjs.org/magic-bytes.js/-/magic-bytes.js-1.10.0.tgz", + "integrity": "sha512-/k20Lg2q8LE5xiaaSkMXk4sfvI+9EGEykFS4b0CHHGWqDYU0bGUFSwchNOMA56D7TCs9GwVTkqe9als1/ns8UQ==", + "license": "MIT" + }, "node_modules/make-dir": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", @@ -10605,6 +10759,7 @@ "version": "2.1.35", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, "license": "MIT", "dependencies": { "mime-db": "1.52.0" @@ -10617,6 +10772,7 @@ "version": "1.52.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -10806,26 +10962,6 @@ "node": ">=18" } }, - "node_modules/node-fetch": { - "version": "2.7.0", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "license": "MIT", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -15264,32 +15400,6 @@ "dev": true, "license": "ISC" }, - "node_modules/prism-media": { - "version": "1.3.5", - "resolved": "https://registry.npmjs.org/prism-media/-/prism-media-1.3.5.tgz", - "integrity": "sha512-IQdl0Q01m4LrkN1EGIE9lphov5Hy7WWlH6ulf5QdGePLlPas9p2mhgddTEHrlaXYjjFToM1/rWuwF37VF4taaA==", - "license": "Apache-2.0", - "peerDependencies": { - "@discordjs/opus": ">=0.8.0 <1.0.0", - "ffmpeg-static": "^5.0.2 || ^4.2.7 || ^3.0.0 || ^2.4.0", - "node-opus": "^0.3.3", - "opusscript": "^0.0.8" - }, - "peerDependenciesMeta": { - "@discordjs/opus": { - "optional": true - }, - "ffmpeg-static": { - "optional": true - }, - "node-opus": { - "optional": true - }, - "opusscript": { - "optional": true - } - } - }, "node_modules/process-nextick-args": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz", @@ -16619,12 +16729,6 @@ "randombytes": "^2.1.0" } }, - "node_modules/setimmediate": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/setimmediate/-/setimmediate-1.0.5.tgz", - "integrity": "sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA==", - "license": "MIT" - }, "node_modules/shallow-clone": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz", @@ -17628,12 +17732,6 @@ "nodetouch": "bin/nodetouch.js" } }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "license": "MIT" - }, "node_modules/traverse": { "version": "0.6.8", "resolved": "https://registry.npmjs.org/traverse/-/traverse-0.6.8.tgz", @@ -17720,6 +17818,12 @@ "node": ">=10" } }, + "node_modules/ts-mixer": { + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/ts-mixer/-/ts-mixer-6.0.4.tgz", + "integrity": "sha512-ufKpbmrugz5Aou4wcr5Wc1UUFWOLhq+Fm6qa6P0w0K5Qw2yhaUoiWszhCVuNQyNwrlGiscHOmqYoAox1PtvgjA==", + "license": "MIT" + }, "node_modules/ts-node": { "version": "10.9.2", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-10.9.2.tgz", @@ -17768,15 +17872,8 @@ "version": "2.8.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.0.tgz", "integrity": "sha512-jWVzBLplnCmoaTr13V9dYbiQ99wvZRd0vNWaDRg+aVYRcjDF3nDksxFDE/+fkXnKhpnUUkmx5pK/v8mCtLVqZA==", - "dev": true, "license": "0BSD" }, - "node_modules/tweetnacl": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz", - "integrity": "sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==", - "license": "Unlicense" - }, "node_modules/type-check": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz", @@ -17872,11 +17969,19 @@ "dev": true, "license": "MIT" }, + "node_modules/undici": { + "version": "6.19.8", + "resolved": "https://registry.npmjs.org/undici/-/undici-6.19.8.tgz", + "integrity": "sha512-U8uCCl2x9TK3WANvmBavymRzxbfFYG+tAu+fgx3zxQy3qdagQqBLwJVrdyO1TBfUXvfKveMKJZhpvUYoOjM+4g==", + "license": "MIT", + "engines": { + "node": ">=18.17" + } + }, "node_modules/undici-types": { "version": "6.19.8", "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz", "integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==", - "dev": true, "license": "MIT" }, "node_modules/unicode-emoji-modifier-base": { @@ -18117,12 +18222,6 @@ "node": ">=10.13.0" } }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "license": "BSD-2-Clause" - }, "node_modules/webpack": { "version": "5.95.0", "resolved": "https://registry.npmjs.org/webpack/-/webpack-5.95.0.tgz", @@ -18277,16 +18376,6 @@ "node": ">=4.0" } }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "license": "MIT", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -18386,16 +18475,16 @@ "license": "ISC" }, "node_modules/ws": { - "version": "7.5.10", - "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", - "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", "license": "MIT", "engines": { - "node": ">=8.3.0" + "node": ">=10.0.0" }, "peerDependencies": { "bufferutil": "^4.0.1", - "utf-8-validate": "^5.0.2" + "utf-8-validate": ">=5.0.2" }, "peerDependenciesMeta": { "bufferutil": { @@ -18571,7 +18660,7 @@ "version": "1.2.0", "dependencies": { "cross-env": "^7.0.2", - "discord.js": "^12.5.1", + "discord.js": "^14.16.3", "dotenv": "^9.0.2", "fs-extra": "^10.0.0", "joi": "^17.4.0", diff --git a/packages/bot/package.json b/packages/bot/package.json index f60b38f..c73d2e7 100644 --- a/packages/bot/package.json +++ b/packages/bot/package.json @@ -5,13 +5,13 @@ "type": "module", "scripts": { "build": "npx swc src -d ./dist", + "deploy:commands": "node --env-file=.env ./dist/framework/discord/deploy-commands.js", "lint": "eslint ./src --report-unused-disable-directives --max-warnings 0 --no-warn-ignored", "lint:fix": "eslint ./src --report-unused-disable-directives --max-warnings 0 --no-warn-ignored --fix", "pretty": "prettier . --ignore-unknown --list-different", "pretty:fix": "npx prettier . --write --ignore-unknown", "release": "npx semantic-release", - "start": "cross-env NODE_ENV=production npm run start:core", - "start:core": "node -r dotenv/config ./dist/index.js", + "start": "node --env-file=.env ./dist/index.js", "test": "exit 0" }, "husky": { @@ -21,7 +21,7 @@ } }, "nodemonConfig": { - "exec": "cross-env TS_NODE_PROJECT='./tsconfig.dev.json' node -r esm -r ts-node/register/transpile-only -r dotenv/config ./src/server/index.ts", + "exec": "cross-env TS_NODE_PROJECT='./tsconfig.dev.json' node -r esm -r ts-node/register/transpile-only --env-file=.env ./src/server/index.ts", "ext": "ts tsx", "ignore": [ "test" @@ -37,9 +37,7 @@ "extends": "semantic-release-monorepo" }, "dependencies": { - "cross-env": "^7.0.2", - "discord.js": "^12.5.1", - "dotenv": "^9.0.2", + "discord.js": "^14.16.3", "fs-extra": "^10.0.0", "joi": "^17.4.0", "neverthrow": "^8.1.1" diff --git a/packages/bot/src/framework/discord/commands/create-character.ts b/packages/bot/src/framework/discord/commands/create-character.ts deleted file mode 100644 index e0f1045..0000000 --- a/packages/bot/src/framework/discord/commands/create-character.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { type ICommand } from '../types' -import { okAsync } from 'neverthrow' - -export default { - name: 'create-character', - description: 'Creates a character', - title: 'Create Character', - execute: () => { - return okAsync('foo') - }, -} as ICommand diff --git a/packages/bot/src/framework/discord/commands/create-chronicle.ts b/packages/bot/src/framework/discord/commands/create-chronicle.ts index b2a4b62..5a36d68 100644 --- a/packages/bot/src/framework/discord/commands/create-chronicle.ts +++ b/packages/bot/src/framework/discord/commands/create-chronicle.ts @@ -1,5 +1,6 @@ import { type ChronicleGateway } from '../../../gateway/chronicle/types' import { type ICommand } from '../types' +import { SlashCommandBuilder } from 'discord.js' import { chronicleMessage } from '../messages/chronicle.js' import { createChronicle } from '../../../use-case/create-chronicle.js' @@ -7,22 +8,33 @@ import { createChronicle } from '../../../use-case/create-chronicle.js' * Handles creating a chronicle (game). This game is tied to the discord server id. */ export default { - name: 'create-chronicle', - description: 'Creates a game.', - title: 'Create Chronicle', - execute( - message, - args: [string, 'vtm', 'v5'], - chronicleGateway: ChronicleGateway - ) { + command: new SlashCommandBuilder() + .setName('game') + .setDescription('Creates a new game tied to this Discord server.') + .addStringOption((option) => + option.setName('name').setDescription('Name of game').setRequired(true) + ) + .addStringOption((option) => + option + .setName('type') + .setDescription('Type of game') + .setRequired(true) + .addChoices({ name: 'VtM - v5', value: 'vtm' }) + ), + execute(interaction, chronicleGateway: ChronicleGateway) { + // Using a TypeGuard here but not sure it should ever get that far?> + // Might be better to make ICommand a generic + if (!interaction.isChatInputCommand()) { + return + } // For each command, we will pass on the fluture but pipe here error results or success results // then the caller can just return the result return createChronicle(chronicleGateway)({ - name: args[0], - referenceId: message.guild.id, + name: interaction.options.getString('name', true), + referenceId: interaction.guild.id, referenceType: 'discord', - game: args[1], - version: args[2], + game: 'vtm', + version: 'v5', }).map(chronicleMessage) }, } as ICommand diff --git a/packages/bot/src/framework/discord/commands/create-player-character.ts b/packages/bot/src/framework/discord/commands/create-player-character.ts deleted file mode 100644 index 9ebdd58..0000000 --- a/packages/bot/src/framework/discord/commands/create-player-character.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { type ICommand } from '../types' -import { okAsync } from 'neverthrow' - -/** - * This will make a player if it doesn't exist and create a character for that player, make sure on subsequent calls that if they already - * created a character from that discord id, you cannot do that again. - */ -export default { - name: 'create-player', - description: 'Creates a player character', - title: 'Create Player', - execute: () => { - return okAsync('') - }, -} as ICommand diff --git a/packages/bot/src/framework/discord/commands/help.ts b/packages/bot/src/framework/discord/commands/help.ts deleted file mode 100644 index 8836714..0000000 --- a/packages/bot/src/framework/discord/commands/help.ts +++ /dev/null @@ -1,30 +0,0 @@ -import type { ICommand } from '../types' -import { commandConfigurations } from '../configurations.js' -import { okAsync } from 'neverthrow' - -/** - * This command returns a list of all possible commands to the caller. - */ -export default { - name: 'help', - description: 'Lists all possible commands', - title: 'Help', - execute: () => { - // This does not need to change realtime - // TODO: This probably belongs in messages - const commandsForHelp = commandConfigurations.map((c) => ({ - name: c.title, - value: `!${c.name} - ${c.description}`, - })) - - return okAsync({ - embed: { - color: 3447003, - title: 'Commands', - fields: commandsForHelp, - timestamp: new Date(), - }, - }) - }, -} as ICommand diff --git a/packages/bot/src/framework/discord/commands/index.ts b/packages/bot/src/framework/discord/commands/index.ts index 7723e7e..e960f0b 100644 --- a/packages/bot/src/framework/discord/commands/index.ts +++ b/packages/bot/src/framework/discord/commands/index.ts @@ -1,16 +1,6 @@ // Import all commands here, quick than trying to dynamically load commands with top level await and forcing // the application to wait to load realtime. import type { ICommand } from '../types.js' -import createCharacter from './create-character.js' import createChronicle from './create-chronicle.js' -import createPlayerCharacter from './create-player-character.js' -import help from './help.js' -import roll from './roll.js' -export const all: ICommand[] = [ - createCharacter, - createChronicle, - createPlayerCharacter, - help, - roll, -] +export const all: ICommand[] = [createChronicle] diff --git a/packages/bot/src/framework/discord/commands/roll.ts b/packages/bot/src/framework/discord/commands/roll.ts deleted file mode 100644 index 11bcc0b..0000000 --- a/packages/bot/src/framework/discord/commands/roll.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { type ICommand } from '../types' -import { okAsync } from 'neverthrow' - -/** - * This command tests the ability of using other bots to handle things like rolling dice. - */ -export default { - name: 'roll', - description: 'Roll Thirst!', - title: 'Roll', - execute: () => { - return okAsync('!v 5 2 5') - }, -} as ICommand diff --git a/packages/bot/src/framework/discord/commands/update-character.ts b/packages/bot/src/framework/discord/commands/update-character.ts deleted file mode 100644 index dabb6f9..0000000 --- a/packages/bot/src/framework/discord/commands/update-character.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { type ICommand } from '../types' -import { okAsync } from 'neverthrow' - -export default { - name: 'update-character', - description: 'Updates a character', - title: 'Update Character', - execute: () => { - // We will need to figure out the best way for a user to update a character - // The biggest thing to figure out is how to handle npcs, without the user - // needing to memorize ids. - // 1) They could look up the character by name, so behind the scenes it would be - // chronicle id, and name - // 2) Or the user displays a list - return okAsync('foo') - }, -} as ICommand diff --git a/packages/bot/src/framework/discord/configurations.ts b/packages/bot/src/framework/discord/configurations.ts index 4821b94..b624753 100644 --- a/packages/bot/src/framework/discord/configurations.ts +++ b/packages/bot/src/framework/discord/configurations.ts @@ -1,19 +1,11 @@ -// import fs from 'fs'; -import Discord from 'discord.js' -import type { ICommand } from './types' +import { Collection } from 'discord.js' +import { type ICommand } from './types' import { all } from './commands/index.js' -// import { endsWith } from '../../utils/string.js'; -// import { dirname } from 'path'; -// import { fileURLToPath } from 'url'; -// const __dirname = dirname(fileURLToPath(import.meta.url)); -// const endsWithJs = endsWith('.js'); -// const commandFiles = fs.readdirSync(`${__dirname}/commands`).filter(endsWithJs); -// const rawCommands = await Promise.all(commandFiles.map(async (file) => import(`${__dirname}/commands/${file}`) as Promise)); +const discordCommands = new Collection() -const discordCommands = new Discord.Collection() all.forEach((command) => { - discordCommands.set(command.name, command) + discordCommands.set(command.command.name, command) }) /** diff --git a/packages/bot/src/framework/discord/deploy-commands.ts b/packages/bot/src/framework/discord/deploy-commands.ts new file mode 100644 index 0000000..8974360 --- /dev/null +++ b/packages/bot/src/framework/discord/deploy-commands.ts @@ -0,0 +1,27 @@ +import { REST, Routes } from 'discord.js' +import { commands } from './configurations.js' + +const { DISCORD_TOKEN, DISCORD_CLIENT_ID, DISCORD_GUILD_ID } = process.env + +const rest = new REST().setToken(DISCORD_TOKEN) + +const slashCommands = commands.map((command) => command.command.toJSON()) + +;(async () => { + try { + console.log(`Started refreshing ${commands.size} application (/) commands.`) + + // The put method is used to fully refresh all commands in the guild with the current set + const data = (await rest.put( + Routes.applicationGuildCommands(DISCORD_CLIENT_ID, DISCORD_GUILD_ID), + { body: slashCommands } + )) as Array + + console.log( + `Successfully reloaded ${data.length} application (/) commands.` + ) + } catch (error) { + // And of course, make sure you catch and log any errors! + console.error(error) + } +})() diff --git a/packages/bot/src/framework/discord/index.ts b/packages/bot/src/framework/discord/index.ts index f805dcc..cc00ea2 100644 --- a/packages/bot/src/framework/discord/index.ts +++ b/packages/bot/src/framework/discord/index.ts @@ -1,74 +1,80 @@ +import { Client, Events, GatewayIntentBits, type Interaction } from 'discord.js' import { type CommandResult, type Result } from './types' -import Discord from 'discord.js' import { chronicleGateway } from '../../gateway/chronicle/rest/index.js' import { commands } from './configurations.js' import { isString } from '../../utils/string.js' import { rest } from '../../service/rest/node.js' -const prefix = '!' - -const sendResult = (message: Discord.Message) => (result: Result) => { - if (isString(result)) { - message.reply(result) - } else { - message.channel.send(result) +const sendResult = (interaction: Interaction) => (result: Result) => { + if (interaction.isChatInputCommand()) { + if (isString(result)) { + interaction.reply(result) + } else { + interaction.channel.send(result) + } } } -const handleResult = (message: Discord.Message) => (result: CommandResult) => { - const sendMessageResult = sendResult(message) +const handleResult = (interaction: Interaction) => (result: CommandResult) => { + const sendMessageResult = sendResult(interaction) result.map(sendMessageResult).mapErr(sendMessageResult) } // Initialize Discord Bot -const client = new Discord.Client() +const client = new Client({ intents: [GatewayIntentBits.Guilds] }) -client.on('ready', () => { +client.once(Events.ClientReady, () => { console.log(`Logged in as ${client.user.tag}!`) }) -client.on('message', (message) => { - console.log( - `Accepting command ${message.content} from user ${message.author.username}:${message.author.id} from server ${message.guild.name}:${message.guild.id}` - ) - if (!message.content.startsWith(prefix) || message.author.bot) { +client.on(Events.InteractionCreate, (interaction) => { + if (!interaction.isChatInputCommand()) { return } - const args = message.content.slice(prefix.length).trim().split(/ +/) - const commandName = args.shift().toLowerCase() + console.log( + `Accepting command ${interaction.commandName} from user ${interaction.member.user.username}:${interaction.member.user.id} from server ${interaction.guild.name}:${interaction.guild.id}` + ) + const command = commands.get(interaction.commandName) + + // if (!message.content.startsWith(prefix) || message.author.bot) { + // return + // } + + // const args = message.content.slice(prefix.length).trim().split(/ +/) + // const commandName = args.shift().toLowerCase() - const command = - commands.get(commandName) || - commands.find((cmd) => cmd.aliases && cmd.aliases.includes(commandName)) + // const command = + // commands.get(commandName) || + // commands.find((cmd) => cmd.aliases && cmd.aliases.includes(commandName)) if (!command) { return } - if (command.guildOnly && message.channel.type === 'dm') { - return message.reply("I can't execute that command inside DMs!") - } + // if (command.guildOnly && message.channel.type === 'dm') { + // return message.reply("I can't execute that command inside DMs!") + // } - if (command.args && !args.length) { - if (command.usage) { - return message.channel.send(` - You didn't provide any arguments, ${message.author}! - The proper usage would be: \`${prefix}${command.name} ${command.usage} - `) - } + // if (command.args && !args.length) { + // if (command.usage) { + // return message.channel.send(` + // You didn't provide any arguments, ${message.author}! + // The proper usage would be: \`${prefix}${command.name} ${command.usage} + // `) + // } - return message.channel.send( - `You didn't provide any arguments, ${message.author}!` - ) - } + // return message.channel.send( + // `You didn't provide any arguments, ${message.author}!` + // ) + // } try { // TODO: As we add more gateways we will want to figure out a better way to pass these in - const result = command.execute(message, args, chronicleGateway(rest)) - handleResult(message)(result) + const result = command.execute(interaction, chronicleGateway(rest)) + handleResult(interaction)(result) } catch (error) { - message.reply( + interaction.reply( `There was an error trying to execute that command! - ${error}` ) } diff --git a/packages/bot/src/framework/discord/messages/character.ts b/packages/bot/src/framework/discord/messages/character.ts deleted file mode 100644 index 5cf78fe..0000000 --- a/packages/bot/src/framework/discord/messages/character.ts +++ /dev/null @@ -1,68 +0,0 @@ -// return { -// embed: { -// color: 3447003, -// author: { -// name: message.author.username -// // icon_url: client.user.avatarURL -// }, -// title: 'Character: Bob - Ravnos', -// url: 'http://google.com', -// // description: 'This is a test embed to showcase what they look like and what they can do.', -// fields: [ -// { -// name: 'Concept', -// value: 'Nomad biker, always on the move' -// }, -// { -// name: 'Ambition', -// value: 'Fight the local Cammies.' -// }, -// { -// name: 'Predator', -// value: 'Foo', -// inline: true -// }, -// { -// name: 'Sire', -// value: 'Bob', -// inline: true -// }, -// { -// name: 'Generation', -// value: '11', -// inline: true -// }, -// { -// name: 'Generation', -// value: '11', -// inline: true -// }, -// { -// name: 'Attributes', -// inline: false, -// value: '\u200b' -// }, -// { -// name: 'Physical', -// inline: true, -// value: '`Strength 1`\n`Dexterity 2`\n`Stamina 3`' -// }, -// { -// name: 'Social', -// inline: true, -// value: '`Charisma 1`\n`Manipulation 2`\n`Composure 3`' -// }, -// { -// name: 'Mental', -// inline: true, -// value: '`Intelligence 1`\n`Witts 2`\n`Resolve 3`' -// } -// ], -// timestamp: new Date(), -// footer: { -// // icon_url: client.user.avatarURL, -// // text: '© Example' -// } -// } -// }; -// } diff --git a/packages/bot/src/framework/discord/messages/chronicle.ts b/packages/bot/src/framework/discord/messages/chronicle.ts index 92ff399..497ded7 100644 --- a/packages/bot/src/framework/discord/messages/chronicle.ts +++ b/packages/bot/src/framework/discord/messages/chronicle.ts @@ -2,21 +2,23 @@ import type { Chronicle } from '../../../entity/chronicle' export const chronicleMessage = (chronicle: Chronicle) => { return { - embed: { - color: 3447003, - title: chronicle.name, - fields: [ - { - name: 'Game', - value: `${chronicle.game} - ${chronicle.version}`, - }, - { - name: 'Created', - // TODO: This should be formatted - value: `${chronicle.created}`, - }, - ], - timestamp: new Date(), - }, + embeds: [ + { + color: 3447003, + title: chronicle.name, + fields: [ + { + name: 'Game', + value: `${chronicle.game} - ${chronicle.version}`, + }, + { + name: 'Created', + // TODO: This should be formatted + value: `${chronicle.created}`, + }, + ], + timestamp: new Date(), + }, + ], } } diff --git a/packages/bot/src/framework/discord/types.ts b/packages/bot/src/framework/discord/types.ts index 7a49f56..63ba57d 100644 --- a/packages/bot/src/framework/discord/types.ts +++ b/packages/bot/src/framework/discord/types.ts @@ -1,18 +1,19 @@ -import { type Message } from 'discord.js' +import { type Interaction, type SlashCommandBuilder } from 'discord.js' import { type ResultAsync } from 'neverthrow' -export type Result = string | string[] | { embed: object } +export type Result = string | { embeds: [object] } export type CommandResult = ResultAsync export interface ICommand { - aliases?: string[] - args?: boolean - description: string + // aliases?: string[] + // args?: boolean + // description: string + command: SlashCommandBuilder // TODO: Figure out types on gateway or how best to pass this is in - execute: (message: Message, args: string[], gateway: unknown) => CommandResult - guildOnly?: boolean - name: string - title: string - usage?: string + execute: (message: Interaction, gateway: unknown) => CommandResult + // guildOnly?: boolean + // name: string + // title: string + // usage?: string } diff --git a/packages/bot/src/index.ts b/packages/bot/src/index.ts index 0aa178d..5d45605 100644 --- a/packages/bot/src/index.ts +++ b/packages/bot/src/index.ts @@ -1,4 +1,4 @@ /** * This file will bootstrap all modules that are used in this service */ -import './frameworks/discord/index.js' +import './framework/discord/index.js'