From 47991395ef5d5ecb6ec9c1ecfe34adb1e6f3ecd7 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 17 Jul 2024 17:28:14 +0100 Subject: [PATCH 01/13] Update appleboy/ssh-action action to v1.0.3 (#303) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [appleboy/ssh-action](https://github.com/appleboy/ssh-action) | action | patch | `v1.0.0` -> `v1.0.3` | --- ### Release Notes
appleboy/ssh-action (appleboy/ssh-action) ### [`v1.0.3`](https://github.com/appleboy/ssh-action/releases/tag/v1.0.3) [Compare Source](https://github.com/appleboy/ssh-action/compare/v1.0.2...v1.0.3) - Support the new parameter `request_pty` to request a pseudo-terminal from the server, addressing the sudo command issue. https://github.com/appleboy/ssh-action/pull/288 ### [`v1.0.2`](https://github.com/appleboy/ssh-action/releases/tag/v1.0.2) [Compare Source](https://github.com/appleboy/ssh-action/compare/v1.0.1...v1.0.2) upgrade ssh-proxy for security patch ### [`v1.0.1`](https://github.com/appleboy/ssh-action/releases/tag/v1.0.1): for security patch [Compare Source](https://github.com/appleboy/ssh-action/compare/v1.0.0...v1.0.1)
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Reviewed-on: https://git.vylpes.xyz/External/card-drop/pulls/303 Reviewed-by: Vylpes Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- .forgejo/workflows/production.yml | 2 +- .forgejo/workflows/stage.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.forgejo/workflows/production.yml b/.forgejo/workflows/production.yml index 1bbf28f..1dd774e 100644 --- a/.forgejo/workflows/production.yml +++ b/.forgejo/workflows/production.yml @@ -30,7 +30,7 @@ jobs: needs: build runs-on: node steps: - - uses: https://github.com/appleboy/ssh-action@v1.0.0 + - uses: https://github.com/appleboy/ssh-action@v1.0.3 env: DB_NAME: ${{ secrets.PROD_DB_NAME }} DB_AUTH_USER: ${{ secrets.PROD_DB_AUTH_USER }} diff --git a/.forgejo/workflows/stage.yml b/.forgejo/workflows/stage.yml index b245d95..8903a70 100644 --- a/.forgejo/workflows/stage.yml +++ b/.forgejo/workflows/stage.yml @@ -30,7 +30,7 @@ jobs: needs: build runs-on: node steps: - - uses: https://github.com/appleboy/ssh-action@v1.0.0 + - uses: https://github.com/appleboy/ssh-action@v1.0.3 env: DB_NAME: ${{ secrets.STAGE_DB_NAME }} DB_AUTH_USER: ${{ secrets.STAGE_DB_AUTH_USER }} From b0b478e1205cd9cbfb2bbdeb187a61909bb40bc0 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Wed, 17 Jul 2024 17:35:09 +0100 Subject: [PATCH 02/13] Update dependency glob to v10.4.5 (#304) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [glob](https://github.com/isaacs/node-glob) | dependencies | patch | [`10.4.3` -> `10.4.5`](https://renovatebot.com/diffs/npm/glob/10.4.3/10.4.5) | --- ### Release Notes
isaacs/node-glob (glob) ### [`v10.4.5`](https://github.com/isaacs/node-glob/compare/v10.4.4...v10.4.5) [Compare Source](https://github.com/isaacs/node-glob/compare/v10.4.4...v10.4.5) ### [`v10.4.4`](https://github.com/isaacs/node-glob/compare/v10.4.3...v10.4.4) [Compare Source](https://github.com/isaacs/node-glob/compare/v10.4.3...v10.4.4)
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Reviewed-on: https://git.vylpes.xyz/External/card-drop/pulls/304 Reviewed-by: Vylpes Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- yarn.lock | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/yarn.lock b/yarn.lock index 04ff1b7..fcc0360 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3217,9 +3217,9 @@ glob-parent@^6.0.2: is-glob "^4.0.3" glob@^10.3.10: - version "10.4.3" - resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.3.tgz#e0ba2253dd21b3d0acdfb5d507c59a29f513fc7a" - integrity sha512-Q38SGlYRpVtDBPSWEylRyctn7uDeTp4NQERTLiCT1FqA9JXPYWqAVmQU6qh4r/zMM5ehxTcbaO8EjhWnvEhmyg== + version "10.4.5" + resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.5.tgz#f4d9f0b90ffdbab09c9d77f5f29b4262517b0956" + integrity sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg== dependencies: foreground-child "^3.1.0" jackspeak "^3.1.2" @@ -3942,9 +3942,9 @@ istanbul-reports@^3.1.3: istanbul-lib-report "^3.0.0" jackspeak@^3.1.2: - version "3.4.1" - resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.4.1.tgz#145422416740568e9fc357bf60c844b3c1585f09" - integrity sha512-U23pQPDnmYybVkYjObcuYMk43VRlMLLqLI+RdZy8s8WV8WsxO9SnqSroKaluuvcNOdCAlauKszDwd+umbot5Mg== + version "3.4.3" + resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.4.3.tgz#8833a9d89ab4acde6188942bd1c53b6390ed5a8a" + integrity sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw== dependencies: "@isaacs/cliui" "^8.0.2" optionalDependencies: @@ -4610,9 +4610,9 @@ lru-cache@^10.0.1: integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ== lru-cache@^10.2.0: - version "10.3.1" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.3.1.tgz#a37050586f84ccfdb570148a253bf1632a29ef44" - integrity sha512-9/8QXrtbGeMB6LxwQd4x1tIMnsmUxMvIH/qWGsccz6bt9Uln3S+sgAaqfQNhbGA8ufzs2fHuP/yqapGgP9Hh2g== + version "10.4.3" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119" + integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ== lru-cache@^5.1.1: version "5.1.1" From f28254e407fd37eee5cb5815584fec645a1e70fd Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Thu, 18 Jul 2024 19:46:23 +0100 Subject: [PATCH 03/13] Add a subseries field to card metadata (#305) - Add an optional "subseries" field to the card metadata function - If this is present, it overrides the main series field #301 Reviewed-on: https://git.vylpes.xyz/External/card-drop/pulls/305 Reviewed-by: VylpesTester Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- src/contracts/SeriesMetadata.ts | 1 + src/helpers/CardDropHelperMetadata.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/contracts/SeriesMetadata.ts b/src/contracts/SeriesMetadata.ts index c363028..4a989bc 100644 --- a/src/contracts/SeriesMetadata.ts +++ b/src/contracts/SeriesMetadata.ts @@ -11,6 +11,7 @@ export interface CardMetadata { name: string, type: CardRarity, path: string, + subseries?: string, } export interface DropResult { diff --git a/src/helpers/CardDropHelperMetadata.ts b/src/helpers/CardDropHelperMetadata.ts index 982661e..84bcdfa 100644 --- a/src/helpers/CardDropHelperMetadata.ts +++ b/src/helpers/CardDropHelperMetadata.ts @@ -81,7 +81,7 @@ export default class CardDropHelperMetadata { public static GenerateDropEmbed(drop: DropResult, quantityClaimed: number, imageFileName: string, claimedBy?: string, currency?: number): EmbedBuilder { AppLogger.LogSilly("CardDropHelperMetadata/GenerateDropEmbed", `Parameters: drop=${drop.card.id}, quantityClaimed=${quantityClaimed}, imageFileName=${imageFileName}`); - const description = drop.series.name; + const description = drop.card.subseries ?? drop.series.name; const embed = new EmbedBuilder() .setTitle(drop.card.name) From b8cd73c5700853ef9176dc59686720ead25d31fa Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 20 Jul 2024 21:42:37 +0100 Subject: [PATCH 04/13] Create allbalance command to get list of everyone's currency (#306) - Create `/allbalance` command for server administrators to be able to get a list of everyone's currency - This will allow admins to adjust and rebalance currency as desired #260 Reviewed-on: https://git.vylpes.xyz/External/card-drop/pulls/306 Reviewed-by: VylpesTester Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- src/commands/allbalance.ts | 28 ++++++++++++++++++++++++++++ src/registry.ts | 2 ++ 2 files changed, 30 insertions(+) create mode 100644 src/commands/allbalance.ts diff --git a/src/commands/allbalance.ts b/src/commands/allbalance.ts new file mode 100644 index 0000000..7db050a --- /dev/null +++ b/src/commands/allbalance.ts @@ -0,0 +1,28 @@ +import { CommandInteraction, EmbedBuilder, PermissionsBitField, SlashCommandBuilder } from "discord.js"; +import EmbedColours from "../constants/EmbedColours"; +import { Command } from "../type/command"; +import User from "../database/entities/app/User"; + +export default class AllBalance extends Command { + constructor() { + super(); + + this.CommandBuilder = new SlashCommandBuilder() + .setName("allbalance") + .setDescription("Get everyone's currency balance") + .setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator); + } + + public override async execute(interaction: CommandInteraction) { + const users = await User.FetchAll(User); + + const filteredUsers = users.filter(x => x.Currency > 0); + + const embed = new EmbedBuilder() + .setColor(EmbedColours.Ok) + .setTitle("All Balances") + .setDescription(filteredUsers.map(x => `<@${x.Id}> ${x.Currency}`).join("\n")); + + await interaction.reply({ embeds: [ embed ], ephemeral: true }); + } +} \ No newline at end of file diff --git a/src/registry.ts b/src/registry.ts index 182418e..86b2b68 100644 --- a/src/registry.ts +++ b/src/registry.ts @@ -3,6 +3,7 @@ import { Environment } from "./constants/Environment"; // Global Command Imports import About from "./commands/about"; +import AllBalance from "./commands/allbalance"; import Balance from "./commands/balance"; import Daily from "./commands/daily"; import Drop from "./commands/drop"; @@ -31,6 +32,7 @@ export default class Registry { public static RegisterCommands() { // Global Commands CoreClient.RegisterCommand("about", new About()); + CoreClient.RegisterCommand("allbalance", new AllBalance()); CoreClient.RegisterCommand("balance", new Balance()); CoreClient.RegisterCommand("daily", new Daily()); CoreClient.RegisterCommand("drop", new Drop()); From 341f3d2bd83e075a3ed86fdc8e587c176842c7c6 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 22 Jul 2024 18:26:09 +0100 Subject: [PATCH 05/13] Update dependency @types/node to v20.14.11 (#307) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [@types/node](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node) ([source](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/node)) | devDependencies | patch | [`20.14.10` -> `20.14.11`](https://renovatebot.com/diffs/npm/@types%2fnode/20.14.10/20.14.11) | --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Reviewed-on: https://git.vylpes.xyz/External/card-drop/pulls/307 Reviewed-by: Vylpes Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- yarn.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/yarn.lock b/yarn.lock index fcc0360..9e7e9a4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1259,9 +1259,9 @@ integrity sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g== "@types/node@^20.0.0": - version "20.14.10" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.14.10.tgz#a1a218290f1b6428682e3af044785e5874db469a" - integrity sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ== + version "20.14.11" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.14.11.tgz#09b300423343460455043ddd4d0ded6ac579b74b" + integrity sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA== dependencies: undici-types "~5.26.4" From a55a5cf5da0b496dfd40feb33498125f74fb0729 Mon Sep 17 00:00:00 2001 From: Renovate Bot Date: Mon, 22 Jul 2024 18:27:30 +0100 Subject: [PATCH 06/13] Update dependency winston to v3.13.1 (#308) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [winston](https://github.com/winstonjs/winston) | dependencies | patch | [`3.13.0` -> `3.13.1`](https://renovatebot.com/diffs/npm/winston/3.13.0/3.13.1) | --- ### Release Notes
winstonjs/winston (winston) ### [`v3.13.1`](https://github.com/winstonjs/winston/releases/tag/v3.13.1) [Compare Source](https://github.com/winstonjs/winston/compare/v3.13.0...v3.13.1) - revert to rimraf 5.0.1, last known version to work with node 18 for now [`1b3a500`](https://github.com/winstonjs/winston/commit/1b3a500) - Merge branch 'master' of github.com:winstonjs/winston [`b56117e`](https://github.com/winstonjs/winston/commit/b56117e) - Update dependencies [`a5853b5`](https://github.com/winstonjs/winston/commit/a5853b5) - Bump [@​types/node](https://github.com/types/node) from 20.12.7 to 20.14.10 ([#​2483](https://github.com/winstonjs/winston/issues/2483)) [`93b52ac`](https://github.com/winstonjs/winston/commit/93b52ac) - Bump mocha from 10.3.0 to 10.6.0 ([#​2484](https://github.com/winstonjs/winston/issues/2484)) [`33611c9`](https://github.com/winstonjs/winston/commit/33611c9) - Bump [@​babel/preset-env](https://github.com/babel/preset-env) from 7.24.0 to 7.24.7 ([#​2475](https://github.com/winstonjs/winston/issues/2475)) [`4aa6550`](https://github.com/winstonjs/winston/commit/4aa6550) - Update minimum version logform ([#​2472](https://github.com/winstonjs/winston/issues/2472)) [`7f5f014`](https://github.com/winstonjs/winston/commit/7f5f014) - Add Parseable transport ([#​2466](https://github.com/winstonjs/winston/issues/2466)) [`debf4fa`](https://github.com/winstonjs/winston/commit/debf4fa) - chore(docs): Update w/ MySQL transport ([#​2456](https://github.com/winstonjs/winston/issues/2456)) [`d567c57`](https://github.com/winstonjs/winston/commit/d567c57) - fix typo at test/unit/winston/transports/http.test.js ([#​2453](https://github.com/winstonjs/winston/issues/2453)) [`1d5d527`](https://github.com/winstonjs/winston/commit/1d5d527) - Bump [@​babel/cli](https://github.com/babel/cli) from 7.23.9 to 7.24.5 ([#​2454](https://github.com/winstonjs/winston/issues/2454)) [`d89a34e`](https://github.com/winstonjs/winston/commit/d89a34e) - Bump [@​types/node](https://github.com/types/node) from 20.11.29 to 20.12.7 ([#​2448](https://github.com/winstonjs/winston/issues/2448)) [`947fa79`](https://github.com/winstonjs/winston/commit/947fa79) - Bump [@​babel/core](https://github.com/babel/core) from 7.24.0 to 7.24.5 ([#​2455](https://github.com/winstonjs/winston/issues/2455)) [`8c58d0a`](https://github.com/winstonjs/winston/commit/8c58d0a)
--- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). Reviewed-on: https://git.vylpes.xyz/External/card-drop/pulls/308 Reviewed-by: Vylpes Co-authored-by: Renovate Bot Co-committed-by: Renovate Bot --- yarn.lock | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/yarn.lock b/yarn.lock index 9e7e9a4..48fe278 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4582,10 +4582,10 @@ logform@2.1.2: ms "^2.1.1" triple-beam "^1.3.0" -logform@^2.3.2, logform@^2.4.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/logform/-/logform-2.6.0.tgz#8c82a983f05d6eaeb2d75e3decae7a768b2bf9b5" - integrity sha512-1ulHeNPp6k/LD8H91o7VYFBng5i1BDE7HoKxVbZiGFidS1Rj65qcywLxX+pVfAPoQJEjRdvKcusKwOupHCVOVQ== +logform@^2.6.0, logform@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/logform/-/logform-2.6.1.tgz#71403a7d8cae04b2b734147963236205db9b3df0" + integrity sha512-CdaO738xRapbKIMVn2m4F6KTj4j7ooJ8POVnebSgKo3KBz5axNXRAL7ZdRjIV6NOr2Uf4vjtRkxrFETOioCqSA== dependencies: "@colors/colors" "1.6.0" "@types/triple-beam" "^1.3.2" @@ -5650,7 +5650,7 @@ readable-stream@^2.3.6: string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@^3.4.0, readable-stream@^3.6.0: +readable-stream@^3.4.0, readable-stream@^3.6.0, readable-stream@^3.6.2: version "3.6.2" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== @@ -6741,24 +6741,24 @@ winston-transport@4.3.0: triple-beam "^1.2.0" winston-transport@^4.7.0: - version "4.7.0" - resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.7.0.tgz#e302e6889e6ccb7f383b926df6936a5b781bd1f0" - integrity sha512-ajBj65K5I7denzer2IYW6+2bNIVqLGDHqDw3Ow8Ohh+vdW+rv4MZ6eiDvHoKhfJFZ2auyN8byXieDDJ96ViONg== + version "4.7.1" + resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.7.1.tgz#52ff1bcfe452ad89991a0aaff9c3b18e7f392569" + integrity sha512-wQCXXVgfv/wUPOfb2x0ruxzwkcZfxcktz6JIMUaPLmcNhO4bZTwA/WtDWK74xV3F2dKu8YadrFv0qhwYjVEwhA== dependencies: - logform "^2.3.2" - readable-stream "^3.6.0" + logform "^2.6.1" + readable-stream "^3.6.2" triple-beam "^1.3.0" winston@^3.11.0: - version "3.13.0" - resolved "https://registry.yarnpkg.com/winston/-/winston-3.13.0.tgz#e76c0d722f78e04838158c61adc1287201de7ce3" - integrity sha512-rwidmA1w3SE4j0E5MuIufFhyJPBDG7Nu71RkZor1p2+qHvJSZ9GYDA81AyleQcZbh/+V6HjeBdfnTZJm9rSeQQ== + version "3.13.1" + resolved "https://registry.yarnpkg.com/winston/-/winston-3.13.1.tgz#53ddadb9c2332eb12cff8306413b3480dc82b6c3" + integrity sha512-SvZit7VFNvXRzbqGHsv5KSmgbEYR5EiQfDAL9gxYkRqa934Hnk++zze0wANKtMHcy/gI4W/3xmSDwlhf865WGw== dependencies: "@colors/colors" "^1.6.0" "@dabh/diagnostics" "^2.0.2" async "^3.2.3" is-stream "^2.0.0" - logform "^2.4.0" + logform "^2.6.0" one-time "^1.0.0" readable-stream "^3.4.0" safe-stable-stringify "^2.3.1" From fef80709eefc87056ca1bc9f0704ed05c18bbb80 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Fri, 26 Jul 2024 18:28:32 +0100 Subject: [PATCH 07/13] Resolve ws to ^8.17.1 (#319) - Upgrade ws to ^8.17.1 to fix vulnerability #269 Reviewed-on: https://git.vylpes.xyz/External/card-drop/pulls/319 Reviewed-by: VylpesTester Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- package.json | 8 ++++---- yarn.lock | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index f37eae6..102b607 100644 --- a/package.json +++ b/package.json @@ -15,11 +15,11 @@ "db:create": "typeorm migration:create ./src/database/migrations/app/new", "release": "np --no-publish" }, - "repository": "https://gitea.vylpes.xyz/External/card-drop.git", + "repository": "https://git.vylpes.xyz/External/card-drop.git", "author": "Ethan Lane ", "license": "MIT", "bugs": { - "url": "https//gitea.vylpes.xyz/External/card-drop/issues", + "url": "https//git.vylpes.xyz/External/card-drop/issues", "email": "helpdesk@vylpes.com" }, "homepage": "https://gitea.vylpes.xyz/External/card-drop", @@ -49,8 +49,8 @@ "winston-daily-rotate-file": "^5.0.0", "winston-discord-transport": "^1.3.0" }, - "overrides": { - "undici": "^5.28.3" + "resolutions": { + "**/ws": "^8.17.1" }, "devDependencies": { "@types/node": "^20.0.0", diff --git a/yarn.lock b/yarn.lock index 48fe278..b953c94 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6838,10 +6838,10 @@ write-file-atomic@^4.0.2: imurmurhash "^0.1.4" signal-exit "^3.0.7" -ws@^8.16.0: - version "8.17.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.0.tgz#d145d18eca2ed25aaf791a183903f7be5e295fea" - integrity sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow== +ws@^8.16.0, ws@^8.17.1: + version "8.18.0" + resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc" + integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw== xdg-basedir@^5.0.1, xdg-basedir@^5.1.0: version "5.1.0" From 097b7284e6b910352313ff0c6d581792c694e01c Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Fri, 26 Jul 2024 18:29:57 +0100 Subject: [PATCH 08/13] Fix list not being sorted (#320) - Fix list on `/allbalance` command not being sorted by currency #260 Reviewed-on: https://git.vylpes.xyz/External/card-drop/pulls/320 Reviewed-by: VylpesTester Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- src/commands/allbalance.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commands/allbalance.ts b/src/commands/allbalance.ts index 7db050a..0874e54 100644 --- a/src/commands/allbalance.ts +++ b/src/commands/allbalance.ts @@ -16,7 +16,8 @@ export default class AllBalance extends Command { public override async execute(interaction: CommandInteraction) { const users = await User.FetchAll(User); - const filteredUsers = users.filter(x => x.Currency > 0); + const filteredUsers = users.filter(x => x.Currency > 0) + .sort((a, b) => b.Currency - a.Currency); const embed = new EmbedBuilder() .setColor(EmbedColours.Ok) From ff9f3e458eaec933c95dc86745f1ebec88fc59b2 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Fri, 26 Jul 2024 18:31:06 +0100 Subject: [PATCH 09/13] Add some unit tests (#321) - Add some unit tests to the project - These aren't massive, more just checks to ensure certain things are as they should - Such as checking all commands are actually registered #15 Reviewed-on: https://git.vylpes.xyz/External/card-drop/pulls/321 Reviewed-by: VylpesTester Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- package.json | 2 +- tests/registry.test.ts | 66 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 tests/registry.test.ts diff --git a/package.json b/package.json index 102b607..3488a56 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "clean": "rm -rf node_modules/ dist/", "build": "tsc", "start": "node ./dist/bot.js", - "test": "jest --passWithNoTests", + "test": "jest", "lint": "eslint .", "lint:fix": "eslint . --fix", "db:up": "typeorm migration:run -d dist/database/dataSources/appDataSource.js", diff --git a/tests/registry.test.ts b/tests/registry.test.ts new file mode 100644 index 0000000..71d80db --- /dev/null +++ b/tests/registry.test.ts @@ -0,0 +1,66 @@ +import {CoreClient} from "../src/client/client"; +import Registry from "../src/registry"; +import fs from "fs"; +import path from "path"; + +describe("RegisterCommands", () => { + test("EXPECT every command in the commands folder to be registered", () => { + const registeredCommands: string[] = []; + + CoreClient.RegisterCommand = jest.fn().mockImplementation((name: string) => { + registeredCommands.push(name); + }); + + Registry.RegisterCommands(); + + const commandFiles = getFilesInDirectory(path.join(process.cwd(), "src", "commands")) + .filter(x => x.endsWith(".ts")); + + for (const file of commandFiles) { + expect(registeredCommands).toContain(file.split("/").pop()!.split(".")[0]); + } + + expect(commandFiles.length).toBe(registeredCommands.length); + }); +}); + +describe("RegisterButtonEvents", () => { + test("EXEPCT every button event in the button events folder to be registered", () => { + const registeredButtonEvents: string[] = []; + + CoreClient.RegisterButtonEvent = jest.fn().mockImplementation((name: string) => { + registeredButtonEvents.push(name); + }); + + Registry.RegisterButtonEvents(); + + const eventFiles = getFilesInDirectory(path.join(process.cwd(), "src", "buttonEvents")) + .filter(x => x.endsWith(".ts")); + + for (const file of eventFiles) { + expect(registeredButtonEvents).toContain(file.split("/").pop()!.split(".")[0].toLowerCase()); + } + + expect(eventFiles.length).toBe(registeredButtonEvents.length); + }); +}); + +function getFilesInDirectory(dir: string): string[] { + let results: string[] = []; + const list = fs.readdirSync(dir); + + list.forEach(file => { + file = path.join(dir, file); + const stat = fs.statSync(file); + + if (stat && stat.isDirectory()) { + /* recurse into a subdirectory */ + results = results.concat(getFilesInDirectory(file)); + } else { + /* is a file */ + results.push(file); + } + }); + + return results; +} From 55e3f5e5dd14607ee2725d44e1404622a3d3c8ba Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Fri, 26 Jul 2024 18:32:12 +0100 Subject: [PATCH 10/13] Document how to start the bot (#322) - Add documentation on how to start the bot #81 Reviewed-on: https://git.vylpes.xyz/External/card-drop/pulls/322 Reviewed-by: VylpesTester Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- README.md | 60 ++++++++++++++++++++++++- docs/cards.md | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 docs/cards.md diff --git a/README.md b/README.md index 94f0c9c..ca4b03f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,60 @@ -# card-drop +# Card Drop + +Card Drop is a Discord Bot designed to allow users to "drop" random cards into +a channel and have the ability to claim them for themselves or let others if +they so choose. + +The cards are randomly chosen based on weights of their card type (i.e. Bronze +is more common than Gold). The user who ran the drop command has 5 minutes to +choose if they want the card to themselves before its claimable by anyone, or +until the drop command is ran again. + +## Installation + +Downloads of the latest version can be found from the [GitHub Releases](https://github.com/vylpes/card-drop/releases) +or [Forgejo Releases](https://git.vylpes.xyz/external/card-drop/releases) page. + +Copy the config template file and fill in the strings. + +## Requirements + +- NodeJS +- Yarn +- Docker + +## Usage + +Install the dependencies and build the app: + +```bash +yarn Install +yarn build +``` + +Setup the database (Recommended to use the docker-compose file + +```bash +docker compose up -d +``` + +Copy and edit the settings file + +```bash +cp .env.template .env +``` + +> **NOTE:** Make sure you do *not* check in these files! These contain +sensitive information and should be treated as private. + +If you're not using `DB_SYNC=true` in `.env`, make sure to migrate the database + +```bash +yarn db:up +``` + +Start the bot + +```bash +yarn start +``` diff --git a/docs/cards.md b/docs/cards.md new file mode 100644 index 0000000..f0be28f --- /dev/null +++ b/docs/cards.md @@ -0,0 +1,120 @@ +# Cards + +This document will describe how to add cards to the bot. This is from the +perspective of the development side and doesn't go into details of syncing +from an external place such as with the Google Drive Sync function. + +The cards will be put into the `$DATA_DIR/cards` folder. `$DATA_DIR` is +configured in the `.env` file. + +## Folder Structure + +The general structure of the cards folder is as follows: + +``` +cards # The main cards folder +| Series 1 # Series folder +| | BRONZE # Type folder +| | | 1000.jpg # Card image +| | | 1001.jpg +| | 1.json # Card metadata file +| Series 2 +| | SILVER +| | | 2000.jpg +| | 2.json +``` + +- The root of the cards folder will have a folder foor each series +- Each series will contain folders for each of the card types containing the + card images. +- The series folder will also contain a metadata JSON folder containing the + metadata of the cards within that series. + +The bot when loading will search the cards folder recursively for each json, +and then read them to determine what cards should be used for the bot. + +## Series Metadata + +An example of what the metadata files could look like are as follows: + +```json +[ + { + "id": 1, + "name": "Series 1", + "cards": [ + { + "id": "1000", + "name": "Card 1000 of Series 1", + "type": 1, + "path": "Series 1/BRONZE/1000.jpg" + }, + { + "id": "1001", + "name": "Card 1001 of Series 1", + "type": 1, + "path": "Series 2/BRONZE?1001.jpg", + "subseries": "Custom Series Name" + } + ] + } +] +``` + +This file will load a series called "Series 1" with the id of 1, containing 2 +cards: +- Card 1000, with type 1 (Bronze), with its image located at (from root) + "Series 1/BRONZE/1000.jpg" +- Card 1001 is the same, except has a custom "subseries" name which will + override the main series name if shown, helpful for an "other" category. + +### Card Type + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NumberNameChanceSacrifice Cost (Coins)
0Unknown--
1Bronze62%5
2Silver31%10
3Gold4.4%30
4Manga2%40
5Legendary0.6%100
From a290eb945aaf83b53e09e2b1094c38fd586e1217 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 27 Jul 2024 16:03:42 +0100 Subject: [PATCH 11/13] 0.8.0 --- .env.example | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.env.example b/.env.example index 009d99c..00a861f 100644 --- a/.env.example +++ b/.env.example @@ -7,7 +7,7 @@ # any secret values. BOT_TOKEN= -BOT_VER=0.7.0 +BOT_VER=0.8.0 BOT_AUTHOR=Vylpes BOT_OWNERID=147392775707426816 BOT_CLIENTID=682942374040961060 From f7a7a3781a8951157691dd241bd5168157e9ed0e Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 27 Jul 2024 16:06:21 +0100 Subject: [PATCH 12/13] Remove tests for now --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3488a56..f67d12f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "clean": "rm -rf node_modules/ dist/", "build": "tsc", "start": "node ./dist/bot.js", - "test": "jest", + "test": "echo true", "lint": "eslint .", "lint:fix": "eslint . --fix", "db:up": "typeorm migration:run -d dist/database/dataSources/appDataSource.js", From 6025e2b269560f059d9810da32c6b084d0464168 Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Sat, 27 Jul 2024 16:06:26 +0100 Subject: [PATCH 13/13] v0.8.0 --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index f67d12f..9126a28 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "card-drop", - "version": "0.7.0", + "version": "0.8.0", "main": "./dist/bot.js", "typings": "./dist", "scripts": { @@ -50,7 +50,7 @@ "winston-discord-transport": "^1.3.0" }, "resolutions": { - "**/ws": "^8.17.1" + "**/ws": "^8.17.1" }, "devDependencies": { "@types/node": "^20.0.0",