Compare commits

..

28 commits

Author SHA1 Message Date
091b8e5205 v0.2.0
All checks were successful
continuous-integration/drone/push Build is passing
2023-11-12 20:56:39 +00:00
4a5f624da3 Add safe mode (#85)
All checks were successful
continuous-integration/drone/push Build is passing
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

#76

## Type of change

Please delete options that are not relevant.

- [x] Bug fix (non-breaking change which fixes an issue)

# How Has This Been Tested?

Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration.

# Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that provde my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/85
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2023-11-12 20:53:50 +00:00
2462ca105a Add syncing with google drive (#75)
All checks were successful
continuous-integration/drone/push Build is passing
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

- Add command (for admins and whitelisted-users only) to sync the google drive folder

#40

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)

# How Has This Been Tested?

Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration.

# Checklist

- [ ] My code follows the style guidelines of this project
- [ ] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [ ] My changes generate no new warnings
- [ ] I have added tests that provde my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/75
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2023-11-10 18:32:08 +00:00
21bef358b3 Remove googleapis dependency (#74)
All checks were successful
continuous-integration/drone/push Build is passing
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

- Remove the `googleapis` dependency which is no longer needed from the project

#52

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)

# How Has This Been Tested?

Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration.

- Have built the project to ensure it still builds

# Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that provde my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/74
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2023-11-10 18:28:21 +00:00
87bef546d3 Add Drop Rarity test command (#73)
All checks were successful
continuous-integration/drone/push Build is passing
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

- Add `/droprarity` test command to help test random rarities
- Remove no-longer-needed `DROP_RARITY` environment variable

#16

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)

# How Has This Been Tested?

Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration.

# Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that provde my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/73
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2023-11-10 18:27:02 +00:00
647e811c64 Update dependency @types/jest to v29.5.7 (#71)
All checks were successful
continuous-integration/drone/push Build is passing
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest) ([source](https://github.com/DefinitelyTyped/DefinitelyTyped)) | dependencies | patch | [`29.5.6` -> `29.5.7`](https://renovatebot.com/diffs/npm/@types%2fjest/29.5.6/29.5.7) |

---

### 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:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/71
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2023-11-06 18:23:29 +00:00
204fd1689f Remove non-required package resolution
All checks were successful
continuous-integration/drone/push Build is passing
2023-11-04 16:11:26 +00:00
0026ab659b Merge branch 'main' into develop 2023-11-04 16:10:41 +00:00
9f6e4f4883 Fix build
All checks were successful
continuous-integration/drone/push Build is passing
2023-11-03 21:58:08 +00:00
08f01c0210 Add google drive sync script (#68)
Some checks failed
continuous-integration/drone/push Build is failing
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

- Add Google Drive Sync script
- Add web hook to allow external scripts to trigger a card database reload

> **NOTE:** This requires extra work once merged, need to implement the cron job for the script on the server

#35

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)

# How Has This Been Tested?

Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration.

- This can't really be tested until its in the stage server, as it requires a server cron job setup
- Have tested the web hook locally with `curl` and that part works

# Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that provde my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/68
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2023-11-03 19:35:49 +00:00
3be95bf1ac Merge branch 'main' into develop
All checks were successful
continuous-integration/drone/push Build is passing
2023-10-28 19:03:15 +01:00
ec2b523702 Add dropnumber test command (#69)
All checks were successful
continuous-integration/drone/push Build is passing
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

- Add `dropnumber` test command, for test servers only
- Remove `DROP_CARD` environment variable

#39

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)

# How Has This Been Tested?

Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration.

- This has been tested locally

# Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that provde my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/69
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2023-10-27 16:02:02 +01:00
28d745bf5c Update dependency @types/uuid to v9.0.6 (#65)
All checks were successful
continuous-integration/drone/push Build is passing
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@types/uuid](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/uuid) ([source](https://github.com/DefinitelyTyped/DefinitelyTyped)) | dependencies | patch | [`9.0.5` -> `9.0.6`](https://renovatebot.com/diffs/npm/@types%2fuuid/9.0.5/9.0.6) |

---

### 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:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/65
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2023-10-23 14:33:18 +01:00
ffc3fcaf89 Update dependency @types/jest to v29.5.6 (#64)
All checks were successful
continuous-integration/drone/push Build is passing
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest) ([source](https://github.com/DefinitelyTyped/DefinitelyTyped)) | dependencies | patch | [`29.5.5` -> `29.5.6`](https://renovatebot.com/diffs/npm/@types%2fjest/29.5.5/29.5.6) |

---

### 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:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/64
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2023-10-23 14:31:52 +01:00
6d1e41d697 Update dependency @types/node to v20.8.7 (#58)
All checks were successful
continuous-integration/drone/push Build is passing
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)) | devDependencies | patch | [`20.8.3` -> `20.8.7`](https://renovatebot.com/diffs/npm/@types%2fnode/20.8.3/20.8.7) |

---

### 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:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/58
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2023-10-23 14:30:07 +01:00
f38d1ef23a Ignore cards.db file
All checks were successful
continuous-integration/drone/push Build is passing
2023-10-21 17:51:49 +01:00
b1aab93fad Merge branch 'main' into develop
Some checks failed
continuous-integration/drone/push Build is failing
2023-10-21 17:50:11 +01:00
ce75d8fab6 Add quantity claimed to drop embed (#61)
All checks were successful
continuous-integration/drone/push Build is passing
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

- Add the quantity which the user has claimed to the drop embed

#37

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)

# How Has This Been Tested?

Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration.

- This has been tested by running the command for a card which has no claimed card and ensure it says 0
- Then reran the command for that card and ensured it says 1

# Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that provde my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/61
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2023-10-20 17:33:22 +01:00
6c78c0f74d Update dependency googleapis to v127 (#59)
All checks were successful
continuous-integration/drone/push Build is passing
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [googleapis](https://github.com/googleapis/google-api-nodejs-client) | dependencies | major | [`^126.0.0` -> `^127.0.0`](https://renovatebot.com/diffs/npm/googleapis/126.0.0/127.0.0) |

---

### 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:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/59
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2023-10-16 19:21:22 +01:00
c24cfc3463 Update dependency jest to v29.7.0 (#41)
All checks were successful
continuous-integration/drone/push Build is passing
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [jest](https://jestjs.io/) ([source](https://github.com/jestjs/jest)) | dependencies | minor | [`29.6.2` -> `29.7.0`](https://renovatebot.com/diffs/npm/jest/29.6.2/29.7.0) |
| [@types/jest](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/jest) ([source](https://github.com/DefinitelyTyped/DefinitelyTyped)) | dependencies | patch | [`29.5.3` -> `29.5.5`](https://renovatebot.com/diffs/npm/@types%2fjest/29.5.3/29.5.5) |

---

### Release Notes

<details>
<summary>jestjs/jest (jest)</summary>

### [`v29.7.0`](55cd6a0aaf...4e56991693)

[Compare Source](55cd6a0aaf...4e56991693)

### [`v29.6.4`](fb7d95c8af...55cd6a0aaf)

[Compare Source](fb7d95c8af...55cd6a0aaf)

### [`v29.6.3`](0fd5b1c375...fb7d95c8af)

[Compare Source](0fd5b1c375...fb7d95c8af)

</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 these updates 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:eyJjcmVhdGVkSW5WZXIiOiIzNi44OS4wIiwidXBkYXRlZEluVmVyIjoiMzcuMC4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCJ9-->

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/41
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2023-10-16 19:19:13 +01:00
53a51fdf96 Allow user to be able to see who claimed what card (#57)
All checks were successful
continuous-integration/drone/push Build is passing
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

- Allow user to be able to see who claimed what card

#24

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)

# How Has This Been Tested?

Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration.

- This has been tested locally by running the claim function and seeing if it mentions me

# Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that provde my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/57
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2023-10-14 17:09:24 +01:00
c5fc2760c4 Add ability to register commands and events to specific environments (#50)
All checks were successful
continuous-integration/drone/push Build is passing
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

- Add ability to register commands and events to specific environments
- These will default to every environment if not specified, so existing commands will still work as is
- Environment is a flag so you can specify multiple environments

#38

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)

# How Has This Been Tested?

Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration.

- This has been tested locally by making sure commands are registered that are specified as the one in the config

# Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that provde my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/50
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2023-10-14 17:07:28 +01:00
ef19adcdfb Update dependency typescript to v5.2.2 (#48)
All checks were successful
continuous-integration/drone/push Build is passing
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [typescript](https://www.typescriptlang.org/) ([source](https://github.com/Microsoft/TypeScript)) | devDependencies | minor | [`5.1.6` -> `5.2.2`](https://renovatebot.com/diffs/npm/typescript/5.1.6/5.2.2) |

---

### 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:eyJjcmVhdGVkSW5WZXIiOiIzNy4wLjAiLCJ1cGRhdGVkSW5WZXIiOiIzNy4wLjAiLCJ0YXJnZXRCcmFuY2giOiJkZXZlbG9wIn0=-->

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/48
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2023-10-09 18:12:57 +01:00
65583f6da2 Update dependency @types/uuid to v9.0.5 (#31)
All checks were successful
continuous-integration/drone/push Build is passing
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@types/uuid](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/uuid) ([source](https://github.com/DefinitelyTyped/DefinitelyTyped)) | dependencies | patch | [`9.0.2` -> `9.0.5`](https://renovatebot.com/diffs/npm/@types%2fuuid/9.0.2/9.0.5) |

---

### 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:eyJjcmVhdGVkSW5WZXIiOiIzNi44OS4wIiwidXBkYXRlZEluVmVyIjoiMzcuMC4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCJ9-->

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/31
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2023-10-09 18:11:56 +01:00
e030cb3757 Update dependency @types/node to v20.8.3 (#42)
All checks were successful
continuous-integration/drone/push Build is passing
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)) | devDependencies | minor | [`20.5.1` -> `20.8.3`](https://renovatebot.com/diffs/npm/@types%2fnode/20.5.1/20.8.3) |

---

### 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:eyJjcmVhdGVkSW5WZXIiOiIzNi44OS4wIiwidXBkYXRlZEluVmVyIjoiMzcuMC4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCJ9-->

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/42
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2023-10-09 11:56:34 +01:00
94c358cfec Update dependency @discordjs/rest to v2 (#21)
All checks were successful
continuous-integration/drone/push Build is passing
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [@discordjs/rest](https://discord.js.org) ([source](https://github.com/discordjs/discord.js)) | dependencies | major | [`^1.1.0` -> `^2.0.0`](https://renovatebot.com/diffs/npm/@discordjs%2frest/1.7.1/2.0.1) |

---

### Release Notes

<details>
<summary>discordjs/discord.js (@&#8203;discordjs/rest)</summary>

### [`v2.0.1`](d04987f09b...84ead6e554)

[Compare Source](d04987f09b...84ead6e554)

### [`v2.0.0`](481bbc924f...d04987f09b)

[Compare Source](481bbc924f...d04987f09b)

</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:eyJjcmVhdGVkSW5WZXIiOiIzNC43NC4yIiwidXBkYXRlZEluVmVyIjoiMzcuMC4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCJ9-->

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/21
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2023-10-09 11:55:47 +01:00
39710843a6 Update dependency minimatch to v9.0.3 (#20)
All checks were successful
continuous-integration/drone/push Build is passing
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [minimatch](https://github.com/isaacs/minimatch) | dependencies | patch | [`9.0.2` -> `9.0.3`](https://renovatebot.com/diffs/npm/minimatch/9.0.2/9.0.3) |

---

### Release Notes

<details>
<summary>isaacs/minimatch (minimatch)</summary>

### [`v9.0.3`](b7bd6d6db0...f8b46a317a)

[Compare Source](b7bd6d6db0...f8b46a317a)

</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:eyJjcmVhdGVkSW5WZXIiOiIzNC43NC4yIiwidXBkYXRlZEluVmVyIjoiMzcuMC4wIiwidGFyZ2V0QnJhbmNoIjoiZGV2ZWxvcCJ9-->

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/20
Reviewed-by: Vylpes <ethan@vylpes.com>
Co-authored-by: Renovate Bot <renovate@vylpes.com>
Co-committed-by: Renovate Bot <renovate@vylpes.com>
2023-10-09 11:55:05 +01:00
4260b120e7 Update random code to select a card out of a pool of all series (#54)
All checks were successful
continuous-integration/drone/push Build is passing
# Description

Please include a summary of the change and which issue is fixed. Please also include relevant motivation and context. List any dependencies that are required for this change.

- Update the randomiser code so that instead of selecting a random series, and then selecting by rarity chance, it now selects a rarity chance, then selects a random card out of all
- This will instead make it so when getting a rarity of a lower quantity of cards, if it selects a series with only 2 cards in it of that type, it won't tend to only be a 50:50 of what one you get

#45

## Type of change

Please delete options that are not relevant.

- [x] New feature (non-breaking change which adds functionality)

# How Has This Been Tested?

Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration.

- This has been tested by making sure that the drop command still works as expected

# Checklist

- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [ ] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that provde my fix is effective or that my feature works
- [ ] New and existing unit tests pass locally with my changes
- [ ] Any dependent changes have been merged and published in downstream modules

Reviewed-on: https://gitea.vylpes.xyz/External/card-drop/pulls/54
Reviewed-by: VylpesTester <tester@vylpes.com>
Co-authored-by: Ethan Lane <ethan@vylpes.com>
Co-committed-by: Ethan Lane <ethan@vylpes.com>
2023-10-06 21:08:08 +01:00
30 changed files with 1164 additions and 720 deletions

View file

@ -7,17 +7,15 @@
# any secret values. # any secret values.
BOT_TOKEN= BOT_TOKEN=
BOT_VER=0.1.8 DEV BOT_VER=0.2 DEV
BOT_AUTHOR=Vylpes BOT_AUTHOR=Vylpes
BOT_OWNERID=147392775707426816 BOT_OWNERID=147392775707426816
BOT_CLIENTID=682942374040961060 BOT_CLIENTID=682942374040961060
BOT_ENV=4
ABOUT_FUNDING= ABOUT_FUNDING=
ABOUT_REPO= ABOUT_REPO=
DROP_RARITY=-1
DROP_CARD=-1
DB_HOST=127.0.0.1 DB_HOST=127.0.0.1
DB_PORT=3301 DB_PORT=3301
DB_NAME=carddrop DB_NAME=carddrop
@ -27,3 +25,8 @@ DB_SYNC=true
DB_LOGGING=true DB_LOGGING=true
DB_CARD_FILE=:memory: DB_CARD_FILE=:memory:
EXPRESS_PORT=3303
GDRIVESYNC_WHITELIST=147392775707426816,887272961504071690
GDRIVESYNC_AUTO=true

1
.gitignore vendored
View file

@ -108,3 +108,4 @@ config.json
ormconfig.json ormconfig.json
gdrive-credentials.json gdrive-credentials.json
cards/ cards/
*.db

View file

@ -7,17 +7,15 @@
# any secret values. # any secret values.
BOT_TOKEN= BOT_TOKEN=
BOT_VER=0.1.8 BOT_VER=0.2
BOT_AUTHOR=Vylpes BOT_AUTHOR=Vylpes
BOT_OWNERID=147392775707426816 BOT_OWNERID=147392775707426816
BOT_CLIENTID=1093810443589529631 BOT_CLIENTID=1093810443589529631
BOT_ENV=1
ABOUT_FUNDING= ABOUT_FUNDING=
ABOUT_REPO= ABOUT_REPO=
DROP_RARITY=-1
DROP_CARD=-1
DB_HOST=127.0.0.1 DB_HOST=127.0.0.1
DB_PORT=3321 DB_PORT=3321
DB_NAME=carddrop DB_NAME=carddrop
@ -27,3 +25,8 @@ DB_SYNC=false
DB_LOGGING=false DB_LOGGING=false
DB_CARD_FILE=:memory: DB_CARD_FILE=:memory:
EXPRESS_PORT=3323
GDRIVESYNC_WHITELIST=147392775707426816,887272961504071690
GDRIVESYNC_AUTO=false

View file

@ -7,17 +7,15 @@
# any secret values. # any secret values.
BOT_TOKEN= BOT_TOKEN=
BOT_VER=0.1.8 BETA BOT_VER=0.2 BETA
BOT_AUTHOR=Vylpes BOT_AUTHOR=Vylpes
BOT_OWNERID=147392775707426816 BOT_OWNERID=147392775707426816
BOT_CLIENTID=1147976642942214235 BOT_CLIENTID=1147976642942214235
BOT_ENV=2
ABOUT_FUNDING= ABOUT_FUNDING=
ABOUT_REPO= ABOUT_REPO=
DROP_RARITY=-1
DROP_CARD=-1
DB_HOST=127.0.0.1 DB_HOST=127.0.0.1
DB_PORT=3311 DB_PORT=3311
DB_NAME=carddrop DB_NAME=carddrop
@ -27,3 +25,8 @@ DB_SYNC=false
DB_LOGGING=false DB_LOGGING=false
DB_CARD_FILE=:memory: DB_CARD_FILE=:memory:
EXPRESS_PORT=3313
GDRIVESYNC_WHITELIST=147392775707426816,887272961504071690
GDRIVESYNC_AUTO=false

View file

@ -0,0 +1,8 @@
CREATE TABLE `config` (
`Id` VARCHAR(255) NOT NULL,
`WhenCreated` DATETIME NOT NULL,
`WhenUpdated` DATETIME NOT NULL,
`Key` VARCHAR(255) NOT NULL,
`Value` VARCHAR(255) NOT NULL,
PRIMARY KEY (`Id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;

View file

@ -1,6 +1,6 @@
{ {
"name": "card-drop", "name": "card-drop",
"version": "0.1.8", "version": "0.2.0",
"main": "./dist/bot.js", "main": "./dist/bot.js",
"typings": "./dist", "typings": "./dist",
"scripts": { "scripts": {
@ -23,22 +23,23 @@
"homepage": "https://gitea.vylpes.xyz/External/card-drop", "homepage": "https://gitea.vylpes.xyz/External/card-drop",
"funding": "https://ko-fi.com/vylpes", "funding": "https://ko-fi.com/vylpes",
"dependencies": { "dependencies": {
"@discordjs/rest": "^1.1.0", "@discordjs/rest": "^2.0.0",
"@types/jest": "^29.5.7", "@types/express": "^4.17.20",
"@types/jest": "^29.0.0",
"@types/uuid": "^9.0.0", "@types/uuid": "^9.0.0",
"body-parser": "^1.20.2",
"discord.js": "^14.3.0", "discord.js": "^14.3.0",
"dotenv": "^16.0.0", "dotenv": "^16.0.0",
"googleapis": "^126.0.0", "express": "^4.18.2",
"jest": "^29.7.0", "jest": "^29.0.0",
"jest-mock-extended": "^3.0.0", "jest-mock-extended": "^3.0.0",
"minimatch": "9.0.2", "minimatch": "9.0.3",
"mysql": "^2.18.1", "mysql": "^2.18.1",
"sqlite3": "^5.1.6", "sqlite3": "^5.1.6",
"ts-jest": "^29.0.0", "ts-jest": "^29.0.0",
"typeorm": "0.3.17" "typeorm": "0.3.17"
}, },
"resolutions": { "resolutions": {
"**/@babel/traverse": "^7.23.2",
"**/undici": "^5.26.2" "**/undici": "^5.26.2"
}, },
"devDependencies": { "devDependencies": {

View file

@ -0,0 +1,5 @@
#!/bin/bash
cd ~/apps/card-drop/card-drop_stage \
&& rclone sync card-drop-gdrive: ./cards \
&& curl -X POST http://localhost:3313/api/reload-db

View file

@ -4,15 +4,22 @@ import Card from "../database/entities/card/Card";
import Series from "../database/entities/card/Series"; import Series from "../database/entities/card/Series";
import path from "path"; import path from "path";
import { CardRarity, CardRarityToString } from "../constants/CardRarity"; import { CardRarity, CardRarityToString } from "../constants/CardRarity";
import Config from "../database/entities/app/Config";
export default class CardSetupFunction { export default class CardSetupFunction {
public async Execute() { public static async Execute() {
if (await Config.GetValue('safemode') == "true") return;
try {
await this.ClearDatabase(); await this.ClearDatabase();
await this.ReadSeries(); await this.ReadSeries();
await this.ReadCards(); await this.ReadCards();
} catch {
await Config.SetValue('safemode', 'true');
}
} }
private async ClearDatabase() { private static async ClearDatabase() {
const cardRepository = CardDataSource.getRepository(Card); const cardRepository = CardDataSource.getRepository(Card);
await cardRepository.clear(); await cardRepository.clear();
@ -20,7 +27,7 @@ export default class CardSetupFunction {
await seriesRepository.clear(); await seriesRepository.clear();
} }
private async ReadSeries() { private static async ReadSeries() {
const seriesDir = readdirSync(path.join(process.cwd(), 'cards')); const seriesDir = readdirSync(path.join(process.cwd(), 'cards'));
const seriesRepository = CardDataSource.getRepository(Series); const seriesRepository = CardDataSource.getRepository(Series);
@ -41,7 +48,7 @@ export default class CardSetupFunction {
await seriesRepository.save(seriesToSave); await seriesRepository.save(seriesToSave);
} }
private async ReadCards() { private static async ReadCards() {
const loadedSeries = await Series.FetchAll(Series, [ "Cards", "Cards.Series" ]); const loadedSeries = await Series.FetchAll(Series, [ "Cards", "Cards.Series" ]);
const cardRepository = CardDataSource.getRepository(Card); const cardRepository = CardDataSource.getRepository(Card);
@ -69,7 +76,7 @@ export default class CardSetupFunction {
console.log(`Loaded ${cardsToSave.length} cards to database`); console.log(`Loaded ${cardsToSave.length} cards to database`);
} }
private GenerateCardData(files: string[], rarity: CardRarity, series: Series): Card[] { private static GenerateCardData(files: string[], rarity: CardRarity, series: Series): Card[] {
const result: Card[] = []; const result: Card[] = [];
for (let file of files.filter(x => !x.startsWith('.') && (x.endsWith('.png') || x.endsWith('.jpg') || x.endsWith('.gif')))) { for (let file of files.filter(x => !x.startsWith('.') && (x.endsWith('.png') || x.endsWith('.jpg') || x.endsWith('.gif')))) {
@ -86,7 +93,7 @@ export default class CardSetupFunction {
return result; return result;
} }
private GetCardFiles(rarity: CardRarity, series: Series): string[] { private static GetCardFiles(rarity: CardRarity, series: Series): string[] {
const folder = path.join(process.cwd(), 'cards', series.Path, CardRarityToString(rarity).toUpperCase()); const folder = path.join(process.cwd(), 'cards', series.Path, CardRarityToString(rarity).toUpperCase());
const folderExists = existsSync(folder); const folderExists = existsSync(folder);

View file

@ -2,6 +2,8 @@ import * as dotenv from "dotenv";
import { CoreClient } from "./client/client"; import { CoreClient } from "./client/client";
import { IntentsBitField } from "discord.js"; import { IntentsBitField } from "discord.js";
import Registry from "./registry"; import Registry from "./registry";
import { existsSync } from "fs";
import { ExecException, exec } from "child_process";
dotenv.config(); dotenv.config();
@ -11,12 +13,15 @@ const requiredConfigs: string[] = [
"BOT_AUTHOR", "BOT_AUTHOR",
"BOT_OWNERID", "BOT_OWNERID",
"BOT_CLIENTID", "BOT_CLIENTID",
"BOT_ENV",
"DB_HOST", "DB_HOST",
"DB_PORT", "DB_PORT",
"DB_AUTH_USER", "DB_AUTH_USER",
"DB_AUTH_PASS", "DB_AUTH_PASS",
"DB_SYNC", "DB_SYNC",
"DB_LOGGING", "DB_LOGGING",
"EXPRESS_PORT",
"GDRIVESYNC_WHITELIST",
] ]
requiredConfigs.forEach(config => { requiredConfigs.forEach(config => {
@ -34,4 +39,20 @@ Registry.RegisterCommands();
Registry.RegisterEvents(); Registry.RegisterEvents();
Registry.RegisterButtonEvents(); Registry.RegisterButtonEvents();
if (!existsSync(`${process.cwd()}/cards`) && process.env.GDRIVESYNC_AUTO && process.env.GDRIVESYNC_AUTO == 'true') {
console.log("Card directory not found, syncing...");
CoreClient.AllowDrops = false;
exec(`rclone sync card-drop-gdrive: ${process.cwd()}/cards`, async (error: ExecException | null) => {
if (error) {
console.error(error.code);
throw `Error while running sync command. Code: ${error.code}`;
} else {
console.log('Synced successfully.');
CoreClient.AllowDrops = true;
}
});
}
client.start(); client.start();

View file

@ -40,6 +40,6 @@ export default class Claim extends ButtonEvent {
await claim.Save(eClaim, claim); await claim.Save(eClaim, claim);
await interaction.reply('Card claimed'); await interaction.reply(`Card claimed by ${interaction.user}`);
} }
} }

View file

@ -1,29 +1,31 @@
import { ActionRowBuilder, AttachmentBuilder, ButtonBuilder, ButtonInteraction, ButtonStyle, CacheType, DiscordAPIError, EmbedBuilder } from "discord.js"; import { AttachmentBuilder, ButtonInteraction, DiscordAPIError } from "discord.js";
import { ButtonEvent } from "../type/buttonEvent"; import { ButtonEvent } from "../type/buttonEvent";
import CardDropHelper from "../helpers/CardDropHelper"; import CardDropHelper from "../helpers/CardDropHelper";
import { readFileSync } from "fs"; import { readFileSync } from "fs";
import { CardRarityToColour, CardRarityToString } from "../constants/CardRarity";
import { v4 } from "uuid"; import { v4 } from "uuid";
import { CoreClient } from "../client/client"; import { CoreClient } from "../client/client";
import Card from "../database/entities/card/Card"; import Inventory from "../database/entities/app/Inventory";
import Config from "../database/entities/app/Config";
export default class Reroll extends ButtonEvent { export default class Reroll extends ButtonEvent {
public override async execute(interaction: ButtonInteraction) { public override async execute(interaction: ButtonInteraction) {
if (!CoreClient.AllowDrops) {
await interaction.reply('Bot is currently syncing, please wait until its done.');
return;
}
if (await Config.GetValue('safemode') == "true")
{
await interaction.reply('Safe Mode has been activated, please resync to contunue.');
return;
}
if (!interaction.guild || !interaction.guildId) return; if (!interaction.guild || !interaction.guildId) return;
let randomCard = await CardDropHelper.GetRandomCard(); let randomCard = await CardDropHelper.GetRandomCard();
if (process.env.DROP_RARITY && Number(process.env.DROP_RARITY) > 0) { if (process.env.DROP_RARITY && Number(process.env.DROP_RARITY) > 0) {
randomCard = await CardDropHelper.GetRandomCardByRarity(Number(process.env.DROP_RARITY)); randomCard = await CardDropHelper.GetRandomCardByRarity(Number(process.env.DROP_RARITY));
} else if (process.env.DROP_CARD && process.env.DROP_CARD != '-1') {
let card = await Card.FetchOneByCardNumber(process.env.DROP_CARD, [ "Series" ]);
if (!card) {
await interaction.reply("Card not found");
return;
}
randomCard = card;
} }
const image = readFileSync(randomCard.Path); const image = readFileSync(randomCard.Path);
@ -32,26 +34,14 @@ export default class Reroll extends ButtonEvent {
const attachment = new AttachmentBuilder(image, { name: randomCard.FileName }); const attachment = new AttachmentBuilder(image, { name: randomCard.FileName });
const embed = new EmbedBuilder() const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, randomCard.CardNumber);
.setTitle(randomCard.Name) const quantityClaimed = inventory ? inventory.Quantity : 0;
.setDescription(randomCard.Series.Name)
.setFooter({ text: CardRarityToString(randomCard.Rarity) })
.setColor(CardRarityToColour(randomCard.Rarity))
.setImage(`attachment://${randomCard.FileName}`);
const row = new ActionRowBuilder<ButtonBuilder>(); const embed = CardDropHelper.GenerateDropEmbed(randomCard, quantityClaimed || 0);
const claimId = v4(); const claimId = v4();
row.addComponents( const row = CardDropHelper.GenerateDropButtons(randomCard, claimId, interaction.user.id);
new ButtonBuilder()
.setCustomId(`claim ${randomCard.CardNumber} ${claimId} ${interaction.user.id}`)
.setLabel("Claim")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId(`reroll`)
.setLabel("Reroll")
.setStyle(ButtonStyle.Secondary));
try { try {
await interaction.editReply({ await interaction.editReply({
@ -62,7 +52,6 @@ export default class Reroll extends ButtonEvent {
} catch (e) { } catch (e) {
console.error(e); console.error(e);
if (e instanceof DiscordAPIError) { if (e instanceof DiscordAPIError) {
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: ${e.code}`); await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: ${e.code}`);
} else { } else {

View file

@ -12,6 +12,8 @@ import CardDataSource from "../database/dataSources/cardDataSource";
import IButtonEventItem from "../contracts/IButtonEventItem"; import IButtonEventItem from "../contracts/IButtonEventItem";
import { ButtonEvent } from "../type/buttonEvent"; import { ButtonEvent } from "../type/buttonEvent";
import AppDataSource from "../database/dataSources/appDataSource"; import AppDataSource from "../database/dataSources/appDataSource";
import { Environment } from "../constants/Environment";
import Webhooks from "../webhooks";
export class CoreClient extends Client { export class CoreClient extends Client {
private static _commandItems: ICommandItem[]; private static _commandItems: ICommandItem[];
@ -20,9 +22,11 @@ export class CoreClient extends Client {
private _events: Events; private _events: Events;
private _util: Util; private _util: Util;
private _cardSetupFunc: CardSetupFunction; private _webhooks: Webhooks;
public static ClaimId: string; public static ClaimId: string;
public static Environment: Environment;
public static AllowDrops: boolean;
public static get commandItems(): ICommandItem[] { public static get commandItems(): ICommandItem[] {
return this._commandItems; return this._commandItems;
@ -46,7 +50,12 @@ export class CoreClient extends Client {
this._events = new Events(); this._events = new Events();
this._util = new Util(); this._util = new Util();
this._cardSetupFunc = new CardSetupFunction(); this._webhooks = new Webhooks();
CoreClient.Environment = Number(process.env.BOT_ENV);
console.log(`Bot Environment: ${CoreClient.Environment}`);
CoreClient.AllowDrops = true;
} }
public async start() { public async start() {
@ -66,39 +75,54 @@ export class CoreClient extends Client {
super.on("interactionCreate", this._events.onInteractionCreate); super.on("interactionCreate", this._events.onInteractionCreate);
super.on("ready", this._events.onReady); super.on("ready", this._events.onReady);
await this._cardSetupFunc.Execute(); await CardSetupFunction.Execute();
await super.login(process.env.BOT_TOKEN);
this._util.loadEvents(this, CoreClient._eventItems); this._util.loadEvents(this, CoreClient._eventItems);
this._util.loadSlashCommands(this); this._util.loadSlashCommands(this);
this._webhooks.start();
console.log(`Registered Commands: ${CoreClient._commandItems.flatMap(x => x.Name).join(", ")}`);
console.log(`Registered Events: ${CoreClient._eventItems.flatMap(x => x.EventType).join(", ")}`);
console.log(`Registered Buttons: ${CoreClient._buttonEvents.flatMap(x => x.ButtonId).join(", ")}`);
await super.login(process.env.BOT_TOKEN);
} }
public static RegisterCommand(name: string, command: Command, serverId?: string) { public static RegisterCommand(name: string, command: Command, environment: Environment = Environment.All, serverId?: string) {
const item: ICommandItem = { const item: ICommandItem = {
Name: name, Name: name,
Environment: environment,
Command: command, Command: command,
ServerId: serverId, ServerId: serverId,
}; };
if (environment &= CoreClient.Environment) {
CoreClient._commandItems.push(item); CoreClient._commandItems.push(item);
} }
}
public static RegisterEvent(eventType: EventType, func: Function) { public static RegisterEvent(eventType: EventType, func: Function, environment: Environment = Environment.All) {
const item: IEventItem = { const item: IEventItem = {
EventType: eventType, EventType: eventType,
ExecutionFunction: func, ExecutionFunction: func,
Environment: environment,
}; };
if (environment &= CoreClient.Environment) {
CoreClient._eventItems.push(item); CoreClient._eventItems.push(item);
} }
}
public static RegisterButtonEvent(buttonId: string, event: ButtonEvent) { public static RegisterButtonEvent(buttonId: string, event: ButtonEvent, environment: Environment = Environment.All) {
const item: IButtonEventItem = { const item: IButtonEventItem = {
ButtonId: buttonId, ButtonId: buttonId,
Event: event, Event: event,
Environment: environment,
}; };
if (environment &= CoreClient.Environment) {
CoreClient._buttonEvents.push(item); CoreClient._buttonEvents.push(item);
} }
} }
}

View file

@ -10,9 +10,15 @@ export class Util {
const globalCommands = registeredCommands.filter(x => !x.ServerId); const globalCommands = registeredCommands.filter(x => !x.ServerId);
const guildCommands = registeredCommands.filter(x => x.ServerId); const guildCommands = registeredCommands.filter(x => x.ServerId);
const globalCommandData: SlashCommandBuilder[] = globalCommands const globalCommandData: SlashCommandBuilder[] = [];
.filter(x => x.Command.CommandBuilder)
.flatMap(x => x.Command.CommandBuilder); for (let command of globalCommands) {
if (!command.Command.CommandBuilder) continue;
if (command.Environment &= CoreClient.Environment) {
globalCommandData.push(command.Command.CommandBuilder);
}
}
const guildIds: string[] = []; const guildIds: string[] = [];
@ -32,9 +38,15 @@ export class Util {
); );
for (let guild of guildIds) { for (let guild of guildIds) {
const guildCommandData = guildCommands.filter(x => x.ServerId == guild) const guildCommandData: SlashCommandBuilder[] = [];
.filter(x => x.Command.CommandBuilder)
.flatMap(x => x.Command.CommandBuilder); for (let command of guildCommands.filter(x => x.ServerId == guild)) {
if (!command.Command.CommandBuilder) continue;
if (command.Environment &= CoreClient.Environment) {
guildCommandData.push(command.Command.CommandBuilder);
}
}
if (!client.guilds.cache.has(guild)) continue; if (!client.guilds.cache.has(guild)) continue;

View file

@ -1,11 +1,11 @@
import { ActionRowBuilder, AttachmentBuilder, ButtonBuilder, ButtonStyle, CommandInteraction, DiscordAPIError, EmbedBuilder, SlashCommandBuilder } from "discord.js"; import { AttachmentBuilder, CommandInteraction, DiscordAPIError, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command"; import { Command } from "../type/command";
import CardDropHelper from "../helpers/CardDropHelper"; import CardDropHelper from "../helpers/CardDropHelper";
import { CardRarityToColour, CardRarityToString } from "../constants/CardRarity";
import { readFileSync } from "fs"; import { readFileSync } from "fs";
import { CoreClient } from "../client/client"; import { CoreClient } from "../client/client";
import { v4 } from "uuid"; import { v4 } from "uuid";
import Card from "../database/entities/card/Card"; import Inventory from "../database/entities/app/Inventory";
import Config from "../database/entities/app/Config";
export default class Drop extends Command { export default class Drop extends Command {
constructor() { constructor() {
@ -17,47 +17,33 @@ export default class Drop extends Command {
} }
public override async execute(interaction: CommandInteraction) { public override async execute(interaction: CommandInteraction) {
let randomCard = await CardDropHelper.GetRandomCard(); if (!CoreClient.AllowDrops) {
await interaction.reply('Bot is currently syncing, please wait until its done.');
if (process.env.DROP_RARITY && Number(process.env.DROP_RARITY) > 0) {
randomCard = await CardDropHelper.GetRandomCardByRarity(Number(process.env.DROP_RARITY));
} else if (process.env.DROP_CARD && process.env.DROP_CARD != '-1') {
let card = await Card.FetchOneByCardNumber(process.env.DROP_CARD, [ "Series" ]);
if (!card) {
await interaction.reply("Card not found");
return; return;
} }
randomCard = card; if (await Config.GetValue('safemode') == "true")
{
await interaction.reply('Safe Mode has been activated, please resync to contunue.');
return;
} }
const randomCard = await CardDropHelper.GetRandomCard();
const image = readFileSync(randomCard.Path); const image = readFileSync(randomCard.Path);
await interaction.deferReply(); await interaction.deferReply();
const attachment = new AttachmentBuilder(image, { name: randomCard.FileName }); const attachment = new AttachmentBuilder(image, { name: randomCard.FileName });
const embed = new EmbedBuilder() const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, randomCard.CardNumber);
.setTitle(randomCard.Name) const quantityClaimed = inventory ? inventory.Quantity : 0;
.setDescription(randomCard.Series.Name)
.setFooter({ text: CardRarityToString(randomCard.Rarity) })
.setColor(CardRarityToColour(randomCard.Rarity))
.setImage(`attachment://${randomCard.FileName}`);
const row = new ActionRowBuilder<ButtonBuilder>(); const embed = CardDropHelper.GenerateDropEmbed(randomCard, quantityClaimed || 0);
const claimId = v4(); const claimId = v4();
row.addComponents( const row = CardDropHelper.GenerateDropButtons(randomCard, claimId, interaction.user.id);
new ButtonBuilder()
.setCustomId(`claim ${randomCard.CardNumber} ${claimId} ${interaction.user.id}`)
.setLabel("Claim")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId(`reroll`)
.setLabel("Reroll")
.setStyle(ButtonStyle.Secondary));
try { try {
await interaction.editReply({ await interaction.editReply({
@ -68,7 +54,6 @@ export default class Drop extends Command {
} catch (e) { } catch (e) {
console.error(e); console.error(e);
if (e instanceof DiscordAPIError) { if (e instanceof DiscordAPIError) {
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: ${e.code}`); await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: ${e.code}`);
} else { } else {

View file

@ -0,0 +1,45 @@
import { CacheType, CommandInteraction, PermissionsBitField, SlashCommandBuilder } from "discord.js";
import { Command } from "../type/command";
import { ExecException, exec } from "child_process";
import CardSetupFunction from "../Functions/CardSetupFunction";
import { CoreClient } from "../client/client";
import Config from "../database/entities/app/Config";
export default class Gdrivesync extends Command {
constructor() {
super();
super.CommandBuilder = new SlashCommandBuilder()
.setName('gdrivesync')
.setDescription('Sync google drive to the bot')
.setDefaultMemberPermissions(PermissionsBitField.Flags.Administrator);
}
public override async execute(interaction: CommandInteraction<CacheType>) {
if (!interaction.isChatInputCommand()) return;
const whitelistedUsers = process.env.GDRIVESYNC_WHITELIST!.split(',');
if (!whitelistedUsers.find(x => x == interaction.user.id)) {
await interaction.reply("Only whitelisted users can use this command.");
return;
}
await interaction.reply('Syncing, this might take a while...');
CoreClient.AllowDrops = false;
exec(`rclone sync card-drop-gdrive: ${process.cwd()}/cards`, async (error: ExecException | null) => {
if (error) {
await interaction.editReply(`Error while running sync command. Safe Mode has been activated. Code: ${error.code}`);
await Config.SetValue('safemode', 'true');
} else {
await CardSetupFunction.Execute();
await interaction.editReply('Synced successfully.');
CoreClient.AllowDrops = true;
await Config.SetValue('safemode', 'false');
}
});
}
}

View file

@ -0,0 +1,76 @@
import { AttachmentBuilder, CacheType, CommandInteraction, DiscordAPIError, SlashCommandBuilder } from "discord.js";
import { Command } from "../../type/command";
import Card from "../../database/entities/card/Card";
import { readFileSync } from "fs";
import Inventory from "../../database/entities/app/Inventory";
import CardDropHelper from "../../helpers/CardDropHelper";
import { v4 } from "uuid";
import { CoreClient } from "../../client/client";
export default class Dropnumber extends Command {
constructor() {
super();
super.CommandBuilder = new SlashCommandBuilder()
.setName('dropnumber')
.setDescription('(TEST) Summon a specific card')
.addStringOption(x =>
x
.setName('cardnumber')
.setDescription('The card number to summon')
.setRequired(true));
}
public override async execute(interaction: CommandInteraction<CacheType>) {
if (!interaction.isChatInputCommand()) return;
const cardNumber = interaction.options.get('cardnumber');
if (!cardNumber || !cardNumber.value) {
await interaction.reply('Card Number is required');
return;
}
const card = await Card.FetchOneByCardNumber(cardNumber.value.toString(), [
"Series"
]);
if (!card) {
await interaction.reply('Card not found');
return;
}
const image = readFileSync(card.Path);
await interaction.deferReply();
const attachment = new AttachmentBuilder(image, { name: card.FileName });
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.CardNumber);
const quantityClaimed = inventory ? inventory.Quantity : 0;
const embed = CardDropHelper.GenerateDropEmbed(card, quantityClaimed || 0);
const claimId = v4();
const row = CardDropHelper.GenerateDropButtons(card, claimId, interaction.user.id);
try {
await interaction.editReply({
embeds: [ embed ],
files: [ attachment ],
components: [ row ],
});
} catch (e) {
console.error(e);
if (e instanceof DiscordAPIError) {
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: ${e.code}`);
} else {
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening.Code: UNKNOWN`);
}
}
CoreClient.ClaimId = claimId;
}
}

View file

@ -0,0 +1,81 @@
import { AttachmentBuilder, CacheType, CommandInteraction, DiscordAPIError, SlashCommandBuilder } from "discord.js";
import { Command } from "../../type/command";
import { CardRarity, CardRarityParse } from "../../constants/CardRarity";
import CardDropHelper from "../../helpers/CardDropHelper";
import { readFileSync } from "fs";
import Inventory from "../../database/entities/app/Inventory";
import { v4 } from "uuid";
import { CoreClient } from "../../client/client";
export default class Droprarity extends Command {
constructor() {
super();
super.CommandBuilder = new SlashCommandBuilder()
.setName('droprarity')
.setDescription('(TEST) Summon a random card of a specific rarity')
.addStringOption(x =>
x
.setName('rarity')
.setDescription('The rarity you want to summon')
.setRequired(true));
}
public override async execute(interaction: CommandInteraction<CacheType>) {
if (!interaction.isChatInputCommand()) return;
const rarity = interaction.options.get('rarity');
if (!rarity || !rarity.value) {
await interaction.reply('Rarity is required');
return;
}
const rarityType = CardRarityParse(rarity.value.toString());
if (rarityType == CardRarity.Unknown) {
await interaction.reply('Invalid rarity');
return;
}
const card = await CardDropHelper.GetRandomCardByRarity(rarityType);
if (!card) {
await interaction.reply('Card not found');
return;
}
const image = readFileSync(card.Path);
await interaction.deferReply();
const attachment = new AttachmentBuilder(image, { name: card.FileName });
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.CardNumber);
const quantityClaimed = inventory ? inventory.Quantity : 0;
const embed = CardDropHelper.GenerateDropEmbed(card, quantityClaimed || 0);
const claimId = v4();
const row = CardDropHelper.GenerateDropButtons(card, claimId, interaction.user.id);
try {
await interaction.editReply({
embeds: [ embed ],
files: [ attachment ],
components: [ row ],
});
} catch (e) {
console.error(e);
if (e instanceof DiscordAPIError) {
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: ${e.code}`);
} else {
await interaction.editReply(`Unable to send next drop. Please try again, and report this if it keeps happening. Code: UNKNOWN`);
}
}
CoreClient.ClaimId = claimId;
}
}

View file

@ -42,3 +42,20 @@ export function CardRarityToColour(rarity: CardRarity): number {
return EmbedColours.MangaCard; return EmbedColours.MangaCard;
} }
} }
export function CardRarityParse(rarity: string): CardRarity {
switch (rarity.toLowerCase()) {
case "bronze":
return CardRarity.Bronze;
case "silver":
return CardRarity.Silver;
case "gold":
return CardRarity.Gold;
case "legendary":
return CardRarity.Legendary;
case "manga":
return CardRarity.Manga;
default:
return CardRarity.Unknown;
}
}

View file

@ -0,0 +1,9 @@
export enum Environment {
None = 0,
Production = 1 << 0,
Stage = 1 << 1,
Local = 1 << 2,
All = Production | Stage | Local,
Test = Stage | Local,
}

View file

@ -1,6 +1,8 @@
import { Environment } from "../constants/Environment";
import { ButtonEvent } from "../type/buttonEvent"; import { ButtonEvent } from "../type/buttonEvent";
export default interface IButtonEventItem { export default interface IButtonEventItem {
ButtonId: string, ButtonId: string,
Event: ButtonEvent, Event: ButtonEvent,
Environment: Environment,
} }

View file

@ -1,7 +1,9 @@
import { Environment } from "../constants/Environment";
import { Command } from "../type/command"; import { Command } from "../type/command";
export default interface ICommandItem { export default interface ICommandItem {
Name: string, Name: string,
Command: Command, Command: Command,
Environment: Environment,
ServerId?: string, ServerId?: string,
} }

View file

@ -1,7 +1,9 @@
import { Environment } from "../constants/Environment";
import { EventType } from "../constants/EventType"; import { EventType } from "../constants/EventType";
export default interface IEventItem { export default interface IEventItem {
EventType: EventType, EventType: EventType,
ExecutionFunction: Function, ExecutionFunction: Function,
Environment: Environment,
} }

View file

@ -0,0 +1,53 @@
import { Column, Entity } from "typeorm";
import AppBaseEntity from "../../../contracts/AppBaseEntity";
import AppDataSource from "../../dataSources/appDataSource";
@Entity()
export default class Config extends AppBaseEntity {
constructor(key: string, value: string) {
super();
this.Key = key;
this.Value = value;
}
@Column()
Key: string;
@Column()
Value: string;
public SetValue(value: string) {
this.Value = value;
}
public static async FetchOneByKey(key: string): Promise<Config | null> {
const repository = AppDataSource.getRepository(Config);
const single = await repository.findOne({ where: { Key: key }});
return single;
}
public static async GetValue(key: string): Promise<string | undefined> {
const config = await Config.FetchOneByKey(key);
if (!config) return undefined;
return config.Value;
}
public static async SetValue(key: string, value: string) {
const config = await Config.FetchOneByKey(key);
if (!config) {
const newConfig = new Config(key, value);
await newConfig.Save(Config, newConfig);
} else {
config.SetValue(value);
await config.Save(Config, config);
}
}
}

View file

@ -0,0 +1,15 @@
import { MigrationInterface, QueryRunner } from "typeorm"
import MigrationHelper from "../../../../helpers/MigrationHelper"
export class CreateConfig1699814500650 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
MigrationHelper.Up('1699814500650-createConfig', '0.2', [
"01-table/Config",
], queryRunner);
}
public async down(queryRunner: QueryRunner): Promise<void> {
}
}

View file

@ -1,7 +1,7 @@
import { CardRarity } from "../constants/CardRarity"; import { ActionRowBuilder, ButtonBuilder, ButtonStyle, EmbedBuilder } from "discord.js";
import { CardRarity, CardRarityToColour, CardRarityToString } from "../constants/CardRarity";
import CardRarityChances from "../constants/CardRarityChances"; import CardRarityChances from "../constants/CardRarityChances";
import Card from "../database/entities/card/Card"; import Card from "../database/entities/card/Card";
import Series from "../database/entities/card/Series";
export default class CardDropHelper { export default class CardDropHelper {
public static async GetRandomCard(): Promise<Card> { public static async GetRandomCard(): Promise<Card> {
@ -20,18 +20,7 @@ export default class CardDropHelper {
else if (randomRarity < mangaChance) cardRarity = CardRarity.Manga; else if (randomRarity < mangaChance) cardRarity = CardRarity.Manga;
else cardRarity = CardRarity.Legendary; else cardRarity = CardRarity.Legendary;
const allSeries = await Series.FetchAll(Series, [ "Cards", "Cards.Series" ]); const randomCard = await this.GetRandomCardByRarity(cardRarity);
const allSeriesWithCards = allSeries.filter(x => x.Cards.length > 0 && x.Cards.find(x => x.Rarity == cardRarity));
const randomSeriesIndex = Math.floor(Math.random() * allSeriesWithCards.length);
const randomSeries = allSeriesWithCards[randomSeriesIndex];
const allCards = randomSeries.Cards.filter(x => x.Rarity == cardRarity && x.Path && x.FileName);
const randomCardIndex = Math.floor(Math.random() * allCards.length);
const randomCard = allCards[randomCardIndex];
return randomCard; return randomCard;
} }
@ -45,4 +34,30 @@ export default class CardDropHelper {
return card; return card;
} }
public static GenerateDropEmbed(card: Card, quantityClaimed: Number): EmbedBuilder {
let description = "";
description += `Series: ${card.Series.Name}\n`;
description += `Claimed: ${quantityClaimed}\n`;
return new EmbedBuilder()
.setTitle(card.Name)
.setDescription(description)
.setFooter({ text: CardRarityToString(card.Rarity) })
.setColor(CardRarityToColour(card.Rarity))
.setImage(`attachment://${card.FileName}`);
}
public static GenerateDropButtons(card: Card, claimId: string, userId: string): ActionRowBuilder<ButtonBuilder> {
return new ActionRowBuilder<ButtonBuilder>()
.addComponents(
new ButtonBuilder()
.setCustomId(`claim ${card.CardNumber} ${claimId} ${userId}`)
.setLabel("Claim")
.setStyle(ButtonStyle.Primary),
new ButtonBuilder()
.setCustomId(`reroll`)
.setLabel("Reroll")
.setStyle(ButtonStyle.Secondary));
}
} }

View file

@ -1,83 +0,0 @@
import { Auth, drive_v3, google } from "googleapis";
import IGDriveFolderListing from "../contracts/IGDriveFolderListing";
import path, { resolve } from "path";
import os from 'os';
import uuid, { v4 } from 'uuid';
import { createWriteStream } from "fs";
export default class GoogleDriveHelper {
private _auth: Auth.GoogleAuth;
private _drive: drive_v3.Drive;
constructor() {
this._auth = new google.auth.GoogleAuth({
keyFile: "gdrive-credentials.json",
scopes: [
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/drive.metadata.readonly",
],
});
this._drive = google.drive( { version: "v3", auth: this._auth });
}
public async listFolder(folderId: string, pageSize: number): Promise<IGDriveFolderListing[]> {
const params = {
pageSize: pageSize,
fields: "nextPageToken, files(id, name)",
q: `'${folderId}' in parents and trashed=false`
}
const res = await this._drive.files.list(params);
return res.data.files as IGDriveFolderListing[];
}
public downloadFile(fileId: string) {
const res = this._drive.files.get({
fileId: fileId,
alt: 'media',
}, {
responseType: 'stream',
})
.then(res => {
return new Promise((resolve, reject) => {
const filePath = path.join(process.cwd(), 'temp', v4());
const dest = createWriteStream(filePath);
let progress = 0;
res.data
.on('end', () => {
resolve(filePath);
})
.on('error', err => {
reject(err);
})
.on('data', d => {
progress += d.length;
})
.pipe(dest);
});
})
}
public async exportFile(fileId: string, mimeType: string) {
const destPath = path.join(process.cwd(), 'temp', v4());
const dest = createWriteStream(destPath);
const res = await this._drive.files.export({
fileId: fileId,
mimeType: mimeType
}, {
responseType: 'stream',
});
await new Promise((resolve, reject) => {
res.data
.on('error', reject)
.pipe(dest)
.on('error', reject)
.on('finish', resolve);
})
}
}

10
src/hooks/ReloadDB.ts Normal file
View file

@ -0,0 +1,10 @@
import { Request, Response } from "express";
import CardSetupFunction from "../Functions/CardSetupFunction";
export default async function ReloadDB(req: Request, res: Response) {
console.log('Reloading Card DB...');
await CardSetupFunction.Execute();
res.sendStatus(200);
}

View file

@ -1,15 +1,29 @@
import { CoreClient } from "./client/client"; import { CoreClient } from "./client/client";
// Global Command Imports
import About from "./commands/about"; import About from "./commands/about";
import Drop from "./commands/drop"; import Drop from "./commands/drop";
import Gdrivesync from "./commands/gdrivesync";
// Test Command Imports
import Dropnumber from "./commands/stage/dropnumber";
import Droprarity from "./commands/stage/droprarity";
// Button Event Imports
import Claim from "./buttonEvents/Claim"; import Claim from "./buttonEvents/Claim";
import Reroll from "./buttonEvents/Reroll"; import Reroll from "./buttonEvents/Reroll";
import { Environment } from "./constants/Environment";
export default class Registry { export default class Registry {
public static RegisterCommands() { public static RegisterCommands() {
// Global Commands
CoreClient.RegisterCommand('about', new About()); CoreClient.RegisterCommand('about', new About());
CoreClient.RegisterCommand('drop', new Drop()); CoreClient.RegisterCommand('drop', new Drop());
CoreClient.RegisterCommand('gdrivesync', new Gdrivesync());
// Test Commands
CoreClient.RegisterCommand('dropnumber', new Dropnumber(), Environment.Test);
CoreClient.RegisterCommand('droprarity', new Droprarity(), Environment.Test);
} }
public static RegisterEvents() { public static RegisterEvents() {

30
src/webhooks.ts Normal file
View file

@ -0,0 +1,30 @@
import bodyParser from "body-parser";
import express, { Application } from "express";
import ReloadDB from "./hooks/ReloadDB";
export default class Webhooks {
private app: Application;
private port = process.env.EXPRESS_PORT!;
public start() {
this.setupApp();
this.setupRoutes();
this.setupListen();
}
private setupApp() {
this.app = express();
this.app.use(bodyParser.json());
}
private setupRoutes() {
this.app.post('/api/reload-db', ReloadDB);
}
private setupListen() {
this.app.listen(this.port, () => {
console.log(`API listening on port ${this.port}`);
});
}
}

1120
yarn.lock

File diff suppressed because it is too large Load diff