Compare commits

...

13 commits

Author SHA1 Message Date
Ethan Lane 6025e2b269 v0.8.0
All checks were successful
Deploy To Production / build (push) Successful in 11s
Deploy To Stage / build (push) Successful in 9s
Deploy To Stage / deploy (push) Successful in 15s
Deploy To Production / deploy (push) Successful in 15s
2024-07-27 16:06:26 +01:00
Ethan Lane f7a7a3781a Remove tests for now 2024-07-27 16:06:21 +01:00
Ethan Lane a290eb945a 0.8.0
All checks were successful
Deploy To Stage / build (push) Successful in 16s
Deploy To Stage / deploy (push) Successful in 16s
2024-07-27 16:03:42 +01:00
Ethan Lane 55e3f5e5dd Document how to start the bot (#322)
All checks were successful
Deploy To Stage / build (push) Successful in 12s
Deploy To Stage / deploy (push) Successful in 16s
- Add documentation on how to start the bot

#81

Reviewed-on: #322
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2024-07-26 18:32:12 +01:00
Ethan Lane ff9f3e458e Add some unit tests (#321)
All checks were successful
Deploy To Stage / build (push) Successful in 12s
Deploy To Stage / deploy (push) Successful in 16s
- 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: #321
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2024-07-26 18:31:06 +01:00
Ethan Lane 097b7284e6 Fix list not being sorted (#320)
All checks were successful
Deploy To Stage / build (push) Successful in 9s
Deploy To Stage / deploy (push) Successful in 17s
- Fix list on `/allbalance` command not being sorted by currency

#260

Reviewed-on: #320
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2024-07-26 18:29:57 +01:00
Ethan Lane fef80709ee Resolve ws to ^8.17.1 (#319)
All checks were successful
Deploy To Stage / build (push) Successful in 10s
Deploy To Stage / deploy (push) Successful in 17s
- Upgrade ws to ^8.17.1 to fix vulnerability

#269

Reviewed-on: #319
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2024-07-26 18:28:32 +01:00
RenovateBot a55a5cf5da Update dependency winston to v3.13.1 (#308)
All checks were successful
Deploy To Stage / build (push) Successful in 9s
Deploy To Stage / deploy (push) Successful in 15s
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

<details>
<summary>winstonjs/winston (winston)</summary>

### [`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 [@&#8203;types/node](https://github.com/types/node) from 20.12.7 to 20.14.10 ([#&#8203;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 ([#&#8203;2484](https://github.com/winstonjs/winston/issues/2484))  [`33611c9`](https://github.com/winstonjs/winston/commit/33611c9)
-   Bump [@&#8203;babel/preset-env](https://github.com/babel/preset-env) from 7.24.0 to 7.24.7 ([#&#8203;2475](https://github.com/winstonjs/winston/issues/2475))  [`4aa6550`](https://github.com/winstonjs/winston/commit/4aa6550)
-   Update minimum version logform ([#&#8203;2472](https://github.com/winstonjs/winston/issues/2472))  [`7f5f014`](https://github.com/winstonjs/winston/commit/7f5f014)
-   Add Parseable transport ([#&#8203;2466](https://github.com/winstonjs/winston/issues/2466))  [`debf4fa`](https://github.com/winstonjs/winston/commit/debf4fa)
-   chore(docs): Update w/ MySQL transport ([#&#8203;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 ([#&#8203;2453](https://github.com/winstonjs/winston/issues/2453))  [`1d5d527`](https://github.com/winstonjs/winston/commit/1d5d527)
-   Bump [@&#8203;babel/cli](https://github.com/babel/cli) from 7.23.9 to 7.24.5 ([#&#8203;2454](https://github.com/winstonjs/winston/issues/2454))  [`d89a34e`](https://github.com/winstonjs/winston/commit/d89a34e)
-   Bump [@&#8203;types/node](https://github.com/types/node) from 20.11.29 to 20.12.7 ([#&#8203;2448](https://github.com/winstonjs/winston/issues/2448))  [`947fa79`](https://github.com/winstonjs/winston/commit/947fa79)
-   Bump [@&#8203;babel/core](https://github.com/babel/core) from 7.24.0 to 7.24.5 ([#&#8203;2455](https://github.com/winstonjs/winston/issues/2455))  [`8c58d0a`](https://github.com/winstonjs/winston/commit/8c58d0a)

</details>

---

### 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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzEuNCIsInVwZGF0ZWRJblZlciI6IjM3LjQzMS40IiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6WyJ0eXBlL2RlcGVuZGVuY2llcyJdfQ==-->

Reviewed-on: #308
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2024-07-22 18:27:30 +01:00
RenovateBot 341f3d2bd8 Update dependency @types/node to v20.14.11 (#307)
All checks were successful
Deploy To Stage / build (push) Successful in 10s
Deploy To Stage / deploy (push) Successful in 16s
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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzEuNCIsInVwZGF0ZWRJblZlciI6IjM3LjQzMS40IiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6WyJ0eXBlL2RlcGVuZGVuY2llcyJdfQ==-->

Reviewed-on: #307
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2024-07-22 18:26:09 +01:00
Ethan Lane b8cd73c570 Create allbalance command to get list of everyone's currency (#306)
All checks were successful
Deploy To Stage / build (push) Successful in 10s
Deploy To Stage / deploy (push) Successful in 17s
- 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: #306
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2024-07-20 21:42:37 +01:00
Ethan Lane f28254e407 Add a subseries field to card metadata (#305)
All checks were successful
Deploy To Stage / build (push) Successful in 9s
Deploy To Stage / deploy (push) Successful in 17s
- Add an optional "subseries" field to the card metadata function
- If this is present, it overrides the main series field

#301

Reviewed-on: #305
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2024-07-18 19:46:23 +01:00
RenovateBot b0b478e120 Update dependency glob to v10.4.5 (#304)
All checks were successful
Deploy To Stage / build (push) Successful in 9s
Deploy To Stage / deploy (push) Successful in 16s
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

<details>
<summary>isaacs/node-glob (glob)</summary>

### [`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)

</details>

---

### 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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzEuNCIsInVwZGF0ZWRJblZlciI6IjM3LjQzMS40IiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6WyJ0eXBlL2RlcGVuZGVuY2llcyJdfQ==-->

Reviewed-on: #304
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2024-07-17 17:35:09 +01:00
RenovateBot 47991395ef Update appleboy/ssh-action action to v1.0.3 (#303)
All checks were successful
Deploy To Stage / build (push) Successful in 11s
Deploy To Stage / deploy (push) Successful in 19s
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

<details>
<summary>appleboy/ssh-action (appleboy/ssh-action)</summary>

### [`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)

</details>

---

### 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.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box

---

This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzEuNCIsInVwZGF0ZWRJblZlciI6IjM3LjQzMS40IiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCIsImxhYmVscyI6WyJ0eXBlL2RlcGVuZGVuY2llcyJdfQ==-->

Reviewed-on: #303
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2024-07-17 17:28:14 +01:00
12 changed files with 317 additions and 41 deletions

View file

@ -7,7 +7,7 @@
# any secret values. # any secret values.
BOT_TOKEN= BOT_TOKEN=
BOT_VER=0.7.0 BOT_VER=0.8.0
BOT_AUTHOR=Vylpes BOT_AUTHOR=Vylpes
BOT_OWNERID=147392775707426816 BOT_OWNERID=147392775707426816
BOT_CLIENTID=682942374040961060 BOT_CLIENTID=682942374040961060

View file

@ -30,7 +30,7 @@ jobs:
needs: build needs: build
runs-on: node runs-on: node
steps: steps:
- uses: https://github.com/appleboy/ssh-action@v1.0.0 - uses: https://github.com/appleboy/ssh-action@v1.0.3
env: env:
DB_NAME: ${{ secrets.PROD_DB_NAME }} DB_NAME: ${{ secrets.PROD_DB_NAME }}
DB_AUTH_USER: ${{ secrets.PROD_DB_AUTH_USER }} DB_AUTH_USER: ${{ secrets.PROD_DB_AUTH_USER }}

View file

@ -30,7 +30,7 @@ jobs:
needs: build needs: build
runs-on: node runs-on: node
steps: steps:
- uses: https://github.com/appleboy/ssh-action@v1.0.0 - uses: https://github.com/appleboy/ssh-action@v1.0.3
env: env:
DB_NAME: ${{ secrets.STAGE_DB_NAME }} DB_NAME: ${{ secrets.STAGE_DB_NAME }}
DB_AUTH_USER: ${{ secrets.STAGE_DB_AUTH_USER }} DB_AUTH_USER: ${{ secrets.STAGE_DB_AUTH_USER }}

View file

@ -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
```

120
docs/cards.md Normal file
View file

@ -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
<table>
<thead>
<tr>
<th>Number</th>
<th>Name</th>
<th>Chance</th>
<th>Sacrifice Cost (Coins)</th>
</tr>
</thead>
<tbody>
<tr>
<td>0</td>
<td>Unknown</td>
<td>-</td>
<td>-</td>
</tr>
<tr>
<td>1</td>
<td>Bronze</td>
<td>62%</td>
<td>5</td>
</tr>
<tr>
<td>2</td>
<td>Silver</td>
<td>31%</td>
<td>10</td>
</tr>
<tr>
<td>3</td>
<td>Gold</td>
<td>4.4%</td>
<td>30</td>
</tr>
<tr>
<td>4</td>
<td>Manga</td>
<td>2%</td>
<td>40</td>
</tr>
<tr>
<td>5</td>
<td>Legendary</td>
<td>0.6%</td>
<td>100</td>
</tr>
</tbody>
</table>

View file

@ -1,13 +1,13 @@
{ {
"name": "card-drop", "name": "card-drop",
"version": "0.7.0", "version": "0.8.0",
"main": "./dist/bot.js", "main": "./dist/bot.js",
"typings": "./dist", "typings": "./dist",
"scripts": { "scripts": {
"clean": "rm -rf node_modules/ dist/", "clean": "rm -rf node_modules/ dist/",
"build": "tsc", "build": "tsc",
"start": "node ./dist/bot.js", "start": "node ./dist/bot.js",
"test": "jest --passWithNoTests", "test": "echo true",
"lint": "eslint .", "lint": "eslint .",
"lint:fix": "eslint . --fix", "lint:fix": "eslint . --fix",
"db:up": "typeorm migration:run -d dist/database/dataSources/appDataSource.js", "db:up": "typeorm migration:run -d dist/database/dataSources/appDataSource.js",
@ -15,11 +15,11 @@
"db:create": "typeorm migration:create ./src/database/migrations/app/new", "db:create": "typeorm migration:create ./src/database/migrations/app/new",
"release": "np --no-publish" "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 <ethan@vylpes.com>", "author": "Ethan Lane <ethan@vylpes.com>",
"license": "MIT", "license": "MIT",
"bugs": { "bugs": {
"url": "https//gitea.vylpes.xyz/External/card-drop/issues", "url": "https//git.vylpes.xyz/External/card-drop/issues",
"email": "helpdesk@vylpes.com" "email": "helpdesk@vylpes.com"
}, },
"homepage": "https://gitea.vylpes.xyz/External/card-drop", "homepage": "https://gitea.vylpes.xyz/External/card-drop",
@ -49,8 +49,8 @@
"winston-daily-rotate-file": "^5.0.0", "winston-daily-rotate-file": "^5.0.0",
"winston-discord-transport": "^1.3.0" "winston-discord-transport": "^1.3.0"
}, },
"overrides": { "resolutions": {
"undici": "^5.28.3" "**/ws": "^8.17.1"
}, },
"devDependencies": { "devDependencies": {
"@types/node": "^20.0.0", "@types/node": "^20.0.0",

View file

@ -0,0 +1,29 @@
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)
.sort((a, b) => b.Currency - a.Currency);
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 });
}
}

View file

@ -11,6 +11,7 @@ export interface CardMetadata {
name: string, name: string,
type: CardRarity, type: CardRarity,
path: string, path: string,
subseries?: string,
} }
export interface DropResult { export interface DropResult {

View file

@ -81,7 +81,7 @@ export default class CardDropHelperMetadata {
public static GenerateDropEmbed(drop: DropResult, quantityClaimed: number, imageFileName: string, claimedBy?: string, currency?: number): EmbedBuilder { 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}`); 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() const embed = new EmbedBuilder()
.setTitle(drop.card.name) .setTitle(drop.card.name)

View file

@ -3,6 +3,7 @@ import { Environment } from "./constants/Environment";
// Global Command Imports // Global Command Imports
import About from "./commands/about"; import About from "./commands/about";
import AllBalance from "./commands/allbalance";
import Balance from "./commands/balance"; import Balance from "./commands/balance";
import Daily from "./commands/daily"; import Daily from "./commands/daily";
import Drop from "./commands/drop"; import Drop from "./commands/drop";
@ -31,6 +32,7 @@ export default class Registry {
public static RegisterCommands() { public static RegisterCommands() {
// Global Commands // Global Commands
CoreClient.RegisterCommand("about", new About()); CoreClient.RegisterCommand("about", new About());
CoreClient.RegisterCommand("allbalance", new AllBalance());
CoreClient.RegisterCommand("balance", new Balance()); CoreClient.RegisterCommand("balance", new Balance());
CoreClient.RegisterCommand("daily", new Daily()); CoreClient.RegisterCommand("daily", new Daily());
CoreClient.RegisterCommand("drop", new Drop()); CoreClient.RegisterCommand("drop", new Drop());

66
tests/registry.test.ts Normal file
View file

@ -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;
}

View file

@ -1259,9 +1259,9 @@
integrity sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g== integrity sha512-QpLcX9ZSsq3YYUUnD3nFDY8H7wctAhQj/TFKL8Ya8v5fMm3CFXxo8zStsLAl780ltoYoo1WvKUVGBQK+1ifr7g==
"@types/node@^20.0.0": "@types/node@^20.0.0":
version "20.14.10" version "20.14.11"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.14.10.tgz#a1a218290f1b6428682e3af044785e5874db469a" resolved "https://registry.yarnpkg.com/@types/node/-/node-20.14.11.tgz#09b300423343460455043ddd4d0ded6ac579b74b"
integrity sha512-MdiXf+nDuMvY0gJKxyfZ7/6UFsETO7mGKF54MVD/ekJS6HdFtpZFBgrh6Pseu64XTb2MLyFPlbW6hj8HYRQNOQ== integrity sha512-kprQpL8MMeszbz6ojB5/tU8PLN4kesnN8Gjzw349rDlNgsSzg90lAVj3llK99Dh7JON+t9AuscPPFW6mPbTnSA==
dependencies: dependencies:
undici-types "~5.26.4" undici-types "~5.26.4"
@ -3217,9 +3217,9 @@ glob-parent@^6.0.2:
is-glob "^4.0.3" is-glob "^4.0.3"
glob@^10.3.10: glob@^10.3.10:
version "10.4.3" version "10.4.5"
resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.3.tgz#e0ba2253dd21b3d0acdfb5d507c59a29f513fc7a" resolved "https://registry.yarnpkg.com/glob/-/glob-10.4.5.tgz#f4d9f0b90ffdbab09c9d77f5f29b4262517b0956"
integrity sha512-Q38SGlYRpVtDBPSWEylRyctn7uDeTp4NQERTLiCT1FqA9JXPYWqAVmQU6qh4r/zMM5ehxTcbaO8EjhWnvEhmyg== integrity sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==
dependencies: dependencies:
foreground-child "^3.1.0" foreground-child "^3.1.0"
jackspeak "^3.1.2" jackspeak "^3.1.2"
@ -3942,9 +3942,9 @@ istanbul-reports@^3.1.3:
istanbul-lib-report "^3.0.0" istanbul-lib-report "^3.0.0"
jackspeak@^3.1.2: jackspeak@^3.1.2:
version "3.4.1" version "3.4.3"
resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.4.1.tgz#145422416740568e9fc357bf60c844b3c1585f09" resolved "https://registry.yarnpkg.com/jackspeak/-/jackspeak-3.4.3.tgz#8833a9d89ab4acde6188942bd1c53b6390ed5a8a"
integrity sha512-U23pQPDnmYybVkYjObcuYMk43VRlMLLqLI+RdZy8s8WV8WsxO9SnqSroKaluuvcNOdCAlauKszDwd+umbot5Mg== integrity sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==
dependencies: dependencies:
"@isaacs/cliui" "^8.0.2" "@isaacs/cliui" "^8.0.2"
optionalDependencies: optionalDependencies:
@ -4582,10 +4582,10 @@ logform@2.1.2:
ms "^2.1.1" ms "^2.1.1"
triple-beam "^1.3.0" triple-beam "^1.3.0"
logform@^2.3.2, logform@^2.4.0: logform@^2.6.0, logform@^2.6.1:
version "2.6.0" version "2.6.1"
resolved "https://registry.yarnpkg.com/logform/-/logform-2.6.0.tgz#8c82a983f05d6eaeb2d75e3decae7a768b2bf9b5" resolved "https://registry.yarnpkg.com/logform/-/logform-2.6.1.tgz#71403a7d8cae04b2b734147963236205db9b3df0"
integrity sha512-1ulHeNPp6k/LD8H91o7VYFBng5i1BDE7HoKxVbZiGFidS1Rj65qcywLxX+pVfAPoQJEjRdvKcusKwOupHCVOVQ== integrity sha512-CdaO738xRapbKIMVn2m4F6KTj4j7ooJ8POVnebSgKo3KBz5axNXRAL7ZdRjIV6NOr2Uf4vjtRkxrFETOioCqSA==
dependencies: dependencies:
"@colors/colors" "1.6.0" "@colors/colors" "1.6.0"
"@types/triple-beam" "^1.3.2" "@types/triple-beam" "^1.3.2"
@ -4610,9 +4610,9 @@ lru-cache@^10.0.1:
integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ== integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==
lru-cache@^10.2.0: lru-cache@^10.2.0:
version "10.3.1" version "10.4.3"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.3.1.tgz#a37050586f84ccfdb570148a253bf1632a29ef44" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.4.3.tgz#410fc8a17b70e598013df257c2446b7f3383f119"
integrity sha512-9/8QXrtbGeMB6LxwQd4x1tIMnsmUxMvIH/qWGsccz6bt9Uln3S+sgAaqfQNhbGA8ufzs2fHuP/yqapGgP9Hh2g== integrity sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==
lru-cache@^5.1.1: lru-cache@^5.1.1:
version "5.1.1" version "5.1.1"
@ -5650,7 +5650,7 @@ readable-stream@^2.3.6:
string_decoder "~1.1.1" string_decoder "~1.1.1"
util-deprecate "~1.0.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" version "3.6.2"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.2.tgz#56a9b36ea965c00c5a93ef31eb111a0f11056967"
integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA== integrity sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==
@ -6741,24 +6741,24 @@ winston-transport@4.3.0:
triple-beam "^1.2.0" triple-beam "^1.2.0"
winston-transport@^4.7.0: winston-transport@^4.7.0:
version "4.7.0" version "4.7.1"
resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.7.0.tgz#e302e6889e6ccb7f383b926df6936a5b781bd1f0" resolved "https://registry.yarnpkg.com/winston-transport/-/winston-transport-4.7.1.tgz#52ff1bcfe452ad89991a0aaff9c3b18e7f392569"
integrity sha512-ajBj65K5I7denzer2IYW6+2bNIVqLGDHqDw3Ow8Ohh+vdW+rv4MZ6eiDvHoKhfJFZ2auyN8byXieDDJ96ViONg== integrity sha512-wQCXXVgfv/wUPOfb2x0ruxzwkcZfxcktz6JIMUaPLmcNhO4bZTwA/WtDWK74xV3F2dKu8YadrFv0qhwYjVEwhA==
dependencies: dependencies:
logform "^2.3.2" logform "^2.6.1"
readable-stream "^3.6.0" readable-stream "^3.6.2"
triple-beam "^1.3.0" triple-beam "^1.3.0"
winston@^3.11.0: winston@^3.11.0:
version "3.13.0" version "3.13.1"
resolved "https://registry.yarnpkg.com/winston/-/winston-3.13.0.tgz#e76c0d722f78e04838158c61adc1287201de7ce3" resolved "https://registry.yarnpkg.com/winston/-/winston-3.13.1.tgz#53ddadb9c2332eb12cff8306413b3480dc82b6c3"
integrity sha512-rwidmA1w3SE4j0E5MuIufFhyJPBDG7Nu71RkZor1p2+qHvJSZ9GYDA81AyleQcZbh/+V6HjeBdfnTZJm9rSeQQ== integrity sha512-SvZit7VFNvXRzbqGHsv5KSmgbEYR5EiQfDAL9gxYkRqa934Hnk++zze0wANKtMHcy/gI4W/3xmSDwlhf865WGw==
dependencies: dependencies:
"@colors/colors" "^1.6.0" "@colors/colors" "^1.6.0"
"@dabh/diagnostics" "^2.0.2" "@dabh/diagnostics" "^2.0.2"
async "^3.2.3" async "^3.2.3"
is-stream "^2.0.0" is-stream "^2.0.0"
logform "^2.4.0" logform "^2.6.0"
one-time "^1.0.0" one-time "^1.0.0"
readable-stream "^3.4.0" readable-stream "^3.4.0"
safe-stable-stringify "^2.3.1" safe-stable-stringify "^2.3.1"
@ -6838,10 +6838,10 @@ write-file-atomic@^4.0.2:
imurmurhash "^0.1.4" imurmurhash "^0.1.4"
signal-exit "^3.0.7" signal-exit "^3.0.7"
ws@^8.16.0: ws@^8.16.0, ws@^8.17.1:
version "8.17.0" version "8.18.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.17.0.tgz#d145d18eca2ed25aaf791a183903f7be5e295fea" resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.0.tgz#0d7505a6eafe2b0e712d232b42279f53bc289bbc"
integrity sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow== integrity sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==
xdg-basedir@^5.0.1, xdg-basedir@^5.1.0: xdg-basedir@^5.0.1, xdg-basedir@^5.1.0:
version "5.1.0" version "5.1.0"