Compare commits
No commits in common. "70d1589584657350ba2778b809bfdd4ce7d7cf8a" and "6c005940851d482f1a3f9683e0dedcc09e238efd" have entirely different histories.
70d1589584
...
6c00594085
17 changed files with 123 additions and 578 deletions
2
.dev.env
2
.dev.env
|
@ -7,7 +7,7 @@
|
|||
# any secret values.
|
||||
|
||||
BOT_TOKEN=
|
||||
BOT_VER=0.5.0
|
||||
BOT_VER=0.4.2
|
||||
BOT_AUTHOR=Vylpes
|
||||
BOT_OWNERID=147392775707426816
|
||||
BOT_CLIENTID=682942374040961060
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# any secret values.
|
||||
|
||||
BOT_TOKEN=
|
||||
BOT_VER=0.5.0
|
||||
BOT_VER=0.4.2
|
||||
BOT_AUTHOR=Vylpes
|
||||
BOT_OWNERID=147392775707426816
|
||||
BOT_CLIENTID=1093810443589529631
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
# any secret values.
|
||||
|
||||
BOT_TOKEN=
|
||||
BOT_VER=0.5.0
|
||||
BOT_VER=0.4.2
|
||||
BOT_AUTHOR=Vylpes
|
||||
BOT_OWNERID=147392775707426816
|
||||
BOT_CLIENTID=1147976642942214235
|
||||
|
|
|
@ -1,47 +0,0 @@
|
|||
steps:
|
||||
build:
|
||||
image: node
|
||||
commands:
|
||||
- npm ci
|
||||
- npm run build
|
||||
when:
|
||||
event: push
|
||||
branch: [ hotfix/*, feature/*, renovate/*, develop, main ]
|
||||
lint:
|
||||
image: node
|
||||
commands:
|
||||
- npm run lint
|
||||
when:
|
||||
event: push
|
||||
branch: [ hotfix/*, feature/*, renovate/*, develop, main ]
|
||||
test:
|
||||
image: node
|
||||
commands:
|
||||
- npm test
|
||||
when:
|
||||
event: push
|
||||
branch: [ hotfix/*, feature/*, renovate/*, develop, main ]
|
||||
stage:
|
||||
image: alpine
|
||||
secrets: [ ssh_key, stage_bot_token ]
|
||||
commands:
|
||||
- apk add rsync openssh-client
|
||||
- eval `ssh-agent -s`
|
||||
- echo "$SSH_KEY" | tr -d '\r' | ssh-add -
|
||||
- rsync -e "ssh -o StrictHostKeyChecking=no" -r ./* vylpes@192.168.68.120:/home/vylpes/apps/card-drop/card-drop_stage
|
||||
- ssh vylpes@192.168.68.120 BOT_TOKEN='$${stage_bot_token}' 'bash -s' < ./scripts/deploy_stage.sh
|
||||
when:
|
||||
event: push
|
||||
branch: [ develop ]
|
||||
deploy:
|
||||
image: alpine
|
||||
secrets: [ ssh_key, prod_bot_token ]
|
||||
commands:
|
||||
- apk add rsync openssh-client
|
||||
- eval `ssh-agent -s`
|
||||
- echo "$SSH_KEY" | tr -d '\r' | ssh-add -
|
||||
- rsync -e "ssh -o StrictHostKeyChecking=no" -r ./* vylpes@192.168.68.120:/home/vylpes/apps/card-drop/card-drop_prod
|
||||
- ssh vylpes@192.168.68.120 BOT_TOKEN='$${prod_bot_token}' 'bash -s' < ./scripts/deploy_prod.sh
|
||||
when:
|
||||
event: push
|
||||
branch: [ main ]
|
402
package-lock.json
generated
402
package-lock.json
generated
|
@ -1,21 +1,19 @@
|
|||
{
|
||||
"name": "card-drop",
|
||||
"version": "0.5.0",
|
||||
"version": "0.4.2",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "card-drop",
|
||||
"version": "0.5.0",
|
||||
"version": "0.4.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@discordjs/rest": "^2.0.0",
|
||||
"@types/clone-deep": "^4.0.4",
|
||||
"@types/express": "^4.17.20",
|
||||
"@types/jest": "^29.0.0",
|
||||
"@types/uuid": "^9.0.0",
|
||||
"body-parser": "^1.20.2",
|
||||
"clone-deep": "^4.0.1",
|
||||
"discord.js": "^14.3.0",
|
||||
"dotenv": "^16.0.0",
|
||||
"express": "^4.18.2",
|
||||
|
@ -25,7 +23,7 @@
|
|||
"minimatch": "9.0.3",
|
||||
"mysql": "^2.18.1",
|
||||
"ts-jest": "^29.0.0",
|
||||
"typeorm": "0.3.20"
|
||||
"typeorm": "0.3.19"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.0.0",
|
||||
|
@ -1787,11 +1785,6 @@
|
|||
"@types/responselike": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/clone-deep": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/clone-deep/-/clone-deep-4.0.4.tgz",
|
||||
"integrity": "sha512-vXh6JuuaAha6sqEbJueYdh5zNBPPgG1OYumuz2UvLvriN6ABHDSW8ludREGWJb1MLIzbwZn4q4zUbUCerJTJfA=="
|
||||
},
|
||||
"node_modules/@types/connect": {
|
||||
"version": "3.4.38",
|
||||
"license": "MIT",
|
||||
|
@ -1854,9 +1847,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@types/jest": {
|
||||
"version": "29.5.12",
|
||||
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.12.tgz",
|
||||
"integrity": "sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==",
|
||||
"version": "29.5.11",
|
||||
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.11.tgz",
|
||||
"integrity": "sha512-S2mHmYIVe13vrm6q4kN6fLYYAka15ALQki/vgDC3mIukEOx8WJlv0kQPM+d4w8Gp6u0uSdKND04IlTXBv0rwnQ==",
|
||||
"dependencies": {
|
||||
"expect": "^29.0.0",
|
||||
"pretty-format": "^29.0.0"
|
||||
|
@ -1881,9 +1874,9 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/node": {
|
||||
"version": "20.11.17",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.11.17.tgz",
|
||||
"integrity": "sha512-QmgQZGWu1Yw9TDyAP9ZzpFJKynYNeOvwMJmaxABfieQoVoiVOS6MN1WSpqpRcbeA5+RW82kraAVxCCJg+780Qw==",
|
||||
"version": "20.10.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.10.7.tgz",
|
||||
"integrity": "sha512-fRbIKb8C/Y2lXxB5eVMj4IU7xpdox0Lh8bUPEdtLysaylsml1hOOx1+STloRs/B9nf7C6kPRmmg/V7aQW7usNg==",
|
||||
"dependencies": {
|
||||
"undici-types": "~5.26.4"
|
||||
}
|
||||
|
@ -1941,9 +1934,8 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/uuid": {
|
||||
"version": "9.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.8.tgz",
|
||||
"integrity": "sha512-jg+97EGIcY9AGHJJRaaPVgetKDsrTgbRjQ5Msgjh/DQKEFl0DtyRr/VCOyD1T2R1MNeWPK/u7JoGhlDZnKBAfA=="
|
||||
"version": "9.0.7",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/ws": {
|
||||
"version": "8.5.9",
|
||||
|
@ -1964,16 +1956,16 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin": {
|
||||
"version": "6.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.18.1.tgz",
|
||||
"integrity": "sha512-nISDRYnnIpk7VCFrGcu1rnZfM1Dh9LRHnfgdkjcbi/l7g16VYRri3TjXi9Ir4lOZSw5N/gnV/3H7jIPQ8Q4daA==",
|
||||
"version": "6.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.16.0.tgz",
|
||||
"integrity": "sha512-O5f7Kv5o4dLWQtPX4ywPPa+v9G+1q1x8mz0Kr0pXUtKsevo+gIJHLkGc8RxaZWtP8RrhwhSNIWThnW42K9/0rQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/regexpp": "^4.5.1",
|
||||
"@typescript-eslint/scope-manager": "6.18.1",
|
||||
"@typescript-eslint/type-utils": "6.18.1",
|
||||
"@typescript-eslint/utils": "6.18.1",
|
||||
"@typescript-eslint/visitor-keys": "6.18.1",
|
||||
"@typescript-eslint/scope-manager": "6.16.0",
|
||||
"@typescript-eslint/type-utils": "6.16.0",
|
||||
"@typescript-eslint/utils": "6.16.0",
|
||||
"@typescript-eslint/visitor-keys": "6.16.0",
|
||||
"debug": "^4.3.4",
|
||||
"graphemer": "^1.4.0",
|
||||
"ignore": "^5.2.4",
|
||||
|
@ -1998,53 +1990,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "6.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.18.1.tgz",
|
||||
"integrity": "sha512-BgdBwXPFmZzaZUuw6wKiHKIovms97a7eTImjkXCZE04TGHysG+0hDQPmygyvgtkoB/aOQwSM/nWv3LzrOIQOBw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "6.18.1",
|
||||
"@typescript-eslint/visitor-keys": "6.18.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^16.0.0 || >=18.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/types": {
|
||||
"version": "6.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.1.tgz",
|
||||
"integrity": "sha512-4TuMAe+tc5oA7wwfqMtB0Y5OrREPF1GeJBAjqwgZh1lEMH5PJQgWgHGfYufVB51LtjD+peZylmeyxUXPfENLCw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^16.0.0 || >=18.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "6.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.1.tgz",
|
||||
"integrity": "sha512-/kvt0C5lRqGoCfsbmm7/CwMqoSkY3zzHLIjdhHZQW3VFrnz7ATecOHR7nb7V+xn4286MBxfnQfQhAmCI0u+bJA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "6.18.1",
|
||||
"eslint-visitor-keys": "^3.4.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^16.0.0 || >=18.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/eslint-plugin/node_modules/debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
|
@ -2137,13 +2082,13 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils": {
|
||||
"version": "6.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.18.1.tgz",
|
||||
"integrity": "sha512-wyOSKhuzHeU/5pcRDP2G2Ndci+4g653V43gXTpt4nbyoIOAASkGDA9JIAgbQCdCkcr1MvpSYWzxTz0olCn8+/Q==",
|
||||
"version": "6.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-6.16.0.tgz",
|
||||
"integrity": "sha512-ThmrEOcARmOnoyQfYkHw/DX2SEYBalVECmoldVuH6qagKROp/jMnfXpAU/pAIWub9c4YTxga+XwgAkoA0pxfmg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/typescript-estree": "6.18.1",
|
||||
"@typescript-eslint/utils": "6.18.1",
|
||||
"@typescript-eslint/typescript-estree": "6.16.0",
|
||||
"@typescript-eslint/utils": "6.16.0",
|
||||
"debug": "^4.3.4",
|
||||
"ts-api-utils": "^1.0.1"
|
||||
},
|
||||
|
@ -2163,64 +2108,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/types": {
|
||||
"version": "6.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.1.tgz",
|
||||
"integrity": "sha512-4TuMAe+tc5oA7wwfqMtB0Y5OrREPF1GeJBAjqwgZh1lEMH5PJQgWgHGfYufVB51LtjD+peZylmeyxUXPfENLCw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^16.0.0 || >=18.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "6.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.18.1.tgz",
|
||||
"integrity": "sha512-fv9B94UAhywPRhUeeV/v+3SBDvcPiLxRZJw/xZeeGgRLQZ6rLMG+8krrJUyIf6s1ecWTzlsbp0rlw7n9sjufHA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "6.18.1",
|
||||
"@typescript-eslint/visitor-keys": "6.18.1",
|
||||
"debug": "^4.3.4",
|
||||
"globby": "^11.1.0",
|
||||
"is-glob": "^4.0.3",
|
||||
"minimatch": "9.0.3",
|
||||
"semver": "^7.5.4",
|
||||
"ts-api-utils": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^16.0.0 || >=18.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils/node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "6.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.1.tgz",
|
||||
"integrity": "sha512-/kvt0C5lRqGoCfsbmm7/CwMqoSkY3zzHLIjdhHZQW3VFrnz7ATecOHR7nb7V+xn4286MBxfnQfQhAmCI0u+bJA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "6.18.1",
|
||||
"eslint-visitor-keys": "^3.4.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^16.0.0 || >=18.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils/node_modules/debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
|
@ -2238,26 +2125,6 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils/node_modules/globby": {
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
|
||||
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"array-union": "^2.1.0",
|
||||
"dir-glob": "^3.0.1",
|
||||
"fast-glob": "^3.2.9",
|
||||
"ignore": "^5.2.0",
|
||||
"merge2": "^1.4.1",
|
||||
"slash": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/type-utils/node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
|
@ -2349,17 +2216,17 @@
|
|||
"dev": true
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils": {
|
||||
"version": "6.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.18.1.tgz",
|
||||
"integrity": "sha512-zZmTuVZvD1wpoceHvoQpOiewmWu3uP9FuTWo8vqpy2ffsmfCE8mklRPi+vmnIYAIk9t/4kOThri2QCDgor+OpQ==",
|
||||
"version": "6.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-6.16.0.tgz",
|
||||
"integrity": "sha512-T83QPKrBm6n//q9mv7oiSvy/Xq/7Hyw9SzSEhMHJwznEmQayfBM87+oAlkNAMEO7/MjIwKyOHgBJbxB0s7gx2A==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@eslint-community/eslint-utils": "^4.4.0",
|
||||
"@types/json-schema": "^7.0.12",
|
||||
"@types/semver": "^7.5.0",
|
||||
"@typescript-eslint/scope-manager": "6.18.1",
|
||||
"@typescript-eslint/types": "6.18.1",
|
||||
"@typescript-eslint/typescript-estree": "6.18.1",
|
||||
"@typescript-eslint/scope-manager": "6.16.0",
|
||||
"@typescript-eslint/types": "6.16.0",
|
||||
"@typescript-eslint/typescript-estree": "6.16.0",
|
||||
"semver": "^7.5.4"
|
||||
},
|
||||
"engines": {
|
||||
|
@ -2373,124 +2240,6 @@
|
|||
"eslint": "^7.0.0 || ^8.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/scope-manager": {
|
||||
"version": "6.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-6.18.1.tgz",
|
||||
"integrity": "sha512-BgdBwXPFmZzaZUuw6wKiHKIovms97a7eTImjkXCZE04TGHysG+0hDQPmygyvgtkoB/aOQwSM/nWv3LzrOIQOBw==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "6.18.1",
|
||||
"@typescript-eslint/visitor-keys": "6.18.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^16.0.0 || >=18.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/types": {
|
||||
"version": "6.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-6.18.1.tgz",
|
||||
"integrity": "sha512-4TuMAe+tc5oA7wwfqMtB0Y5OrREPF1GeJBAjqwgZh1lEMH5PJQgWgHGfYufVB51LtjD+peZylmeyxUXPfENLCw==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"node": "^16.0.0 || >=18.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/typescript-estree": {
|
||||
"version": "6.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-6.18.1.tgz",
|
||||
"integrity": "sha512-fv9B94UAhywPRhUeeV/v+3SBDvcPiLxRZJw/xZeeGgRLQZ6rLMG+8krrJUyIf6s1ecWTzlsbp0rlw7n9sjufHA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "6.18.1",
|
||||
"@typescript-eslint/visitor-keys": "6.18.1",
|
||||
"debug": "^4.3.4",
|
||||
"globby": "^11.1.0",
|
||||
"is-glob": "^4.0.3",
|
||||
"minimatch": "9.0.3",
|
||||
"semver": "^7.5.4",
|
||||
"ts-api-utils": "^1.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^16.0.0 || >=18.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"typescript": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils/node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "6.18.1",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.18.1.tgz",
|
||||
"integrity": "sha512-/kvt0C5lRqGoCfsbmm7/CwMqoSkY3zzHLIjdhHZQW3VFrnz7ATecOHR7nb7V+xn4286MBxfnQfQhAmCI0u+bJA==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"@typescript-eslint/types": "6.18.1",
|
||||
"eslint-visitor-keys": "^3.4.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^16.0.0 || >=18.0.0"
|
||||
},
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/typescript-eslint"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils/node_modules/debug": {
|
||||
"version": "4.3.4",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
|
||||
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"ms": "2.1.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"supports-color": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils/node_modules/globby": {
|
||||
"version": "11.1.0",
|
||||
"resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
|
||||
"integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"array-union": "^2.1.0",
|
||||
"dir-glob": "^3.0.1",
|
||||
"fast-glob": "^3.2.9",
|
||||
"ignore": "^5.2.0",
|
||||
"merge2": "^1.4.1",
|
||||
"slash": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/@typescript-eslint/utils/node_modules/ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@typescript-eslint/visitor-keys": {
|
||||
"version": "6.16.0",
|
||||
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-6.16.0.tgz",
|
||||
|
@ -3795,19 +3544,6 @@
|
|||
"node": ">=0.8"
|
||||
}
|
||||
},
|
||||
"node_modules/clone-deep": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/clone-deep/-/clone-deep-4.0.1.tgz",
|
||||
"integrity": "sha512-neHB9xuzh/wk0dIHweyAXv2aPGZIVk3pLMe+/RNzINf17fe0OG96QroktYAUm7SM1PBnzTabaLboqqxDyMU+SQ==",
|
||||
"dependencies": {
|
||||
"is-plain-object": "^2.0.4",
|
||||
"kind-of": "^6.0.2",
|
||||
"shallow-clone": "^3.0.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/clone-response": {
|
||||
"version": "1.0.3",
|
||||
"dev": true,
|
||||
|
@ -4432,9 +4168,8 @@
|
|||
}
|
||||
},
|
||||
"node_modules/dotenv": {
|
||||
"version": "16.3.2",
|
||||
"resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.3.2.tgz",
|
||||
"integrity": "sha512-HTlk5nmhkm8F6JcdXvHIzaorzCoziNQT9mGxLPVXW8wJF1TiGSL60ZGB4gHWabHOaMmWmhvk2/lPHfnBiT78AQ==",
|
||||
"version": "16.3.1",
|
||||
"license": "BSD-2-Clause",
|
||||
"engines": {
|
||||
"node": ">=12"
|
||||
},
|
||||
|
@ -6445,17 +6180,6 @@
|
|||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/is-plain-object": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
|
||||
"integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==",
|
||||
"dependencies": {
|
||||
"isobject": "^3.0.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/is-promise": {
|
||||
"version": "2.2.2",
|
||||
"dev": true,
|
||||
|
@ -6531,14 +6255,6 @@
|
|||
"version": "2.0.0",
|
||||
"license": "ISC"
|
||||
},
|
||||
"node_modules/isobject": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz",
|
||||
"integrity": "sha512-WhB9zCku7EGTj/HQQRz5aUQEUeoQZH2bWcltRErOpymJ4boYE6wL9Tbr23krRPSZ+C5zqNSrSw+Cc7sZZ4b7vg==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/issue-regex": {
|
||||
"version": "4.1.0",
|
||||
"dev": true,
|
||||
|
@ -7339,14 +7055,6 @@
|
|||
"json-buffer": "3.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/kind-of": {
|
||||
"version": "6.0.3",
|
||||
"resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
|
||||
"integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
},
|
||||
"node_modules/kleur": {
|
||||
"version": "3.0.3",
|
||||
"license": "MIT",
|
||||
|
@ -9914,9 +9622,8 @@
|
|||
"license": "MIT"
|
||||
},
|
||||
"node_modules/reflect-metadata": {
|
||||
"version": "0.2.1",
|
||||
"resolved": "https://registry.npmjs.org/reflect-metadata/-/reflect-metadata-0.2.1.tgz",
|
||||
"integrity": "sha512-i5lLI6iw9AU3Uu4szRNPPEkomnkjRTaVt9hy/bn5g/oSzekBSMeLZblcjP74AW0vBabqERLLIrz+gR8QYR54Tw=="
|
||||
"version": "0.1.13",
|
||||
"license": "Apache-2.0"
|
||||
},
|
||||
"node_modules/registry-auth-token": {
|
||||
"version": "4.2.2",
|
||||
|
@ -10289,17 +9996,6 @@
|
|||
"sha.js": "bin.js"
|
||||
}
|
||||
},
|
||||
"node_modules/shallow-clone": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/shallow-clone/-/shallow-clone-3.0.1.tgz",
|
||||
"integrity": "sha512-/6KqX+GVUdqPuPPd2LxDDxzX6CAbjJehAAOKlNpqqUpAqPM6HeL8f+o3a+JsyGjn2lv0WY8UsTgUJjU9Ok55NA==",
|
||||
"dependencies": {
|
||||
"kind-of": "^6.0.2"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
}
|
||||
},
|
||||
"node_modules/shebang-command": {
|
||||
"version": "2.0.0",
|
||||
"license": "MIT",
|
||||
|
@ -10975,9 +10671,8 @@
|
|||
}
|
||||
},
|
||||
"node_modules/ts-jest": {
|
||||
"version": "29.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ts-jest/-/ts-jest-29.1.2.tgz",
|
||||
"integrity": "sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==",
|
||||
"version": "29.1.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"bs-logger": "0.x",
|
||||
"fast-json-stable-stringify": "2.x",
|
||||
|
@ -10992,7 +10687,7 @@
|
|||
"ts-jest": "cli.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^16.10.0 || ^18.0.0 || >=20.0.0"
|
||||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@babel/core": ">=7.0.0-beta.0 <8",
|
||||
|
@ -11016,6 +10711,21 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/ts-jest/node_modules/jest-util": {
|
||||
"version": "29.6.2",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jest/types": "^29.6.1",
|
||||
"@types/node": "*",
|
||||
"chalk": "^4.0.0",
|
||||
"ci-info": "^3.2.0",
|
||||
"graceful-fs": "^4.2.9",
|
||||
"picomatch": "^2.2.3"
|
||||
},
|
||||
"engines": {
|
||||
"node": "^14.15.0 || ^16.10.0 || >=18.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/ts-mixer": {
|
||||
"version": "6.0.3",
|
||||
"license": "MIT"
|
||||
|
@ -11074,9 +10784,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/typeorm": {
|
||||
"version": "0.3.20",
|
||||
"resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.20.tgz",
|
||||
"integrity": "sha512-sJ0T08dV5eoZroaq9uPKBoNcGslHBR4E4y+EBHs//SiGbblGe7IeduP/IH4ddCcj0qp3PHwDwGnuvqEAnKlq/Q==",
|
||||
"version": "0.3.19",
|
||||
"resolved": "https://registry.npmjs.org/typeorm/-/typeorm-0.3.19.tgz",
|
||||
"integrity": "sha512-OGelrY5qEoAU80mR1iyvmUHiKCPUydL6xp6bebXzS7jyv/X70Gp/jBWRAfF4qGOfy2A7orMiGRfwsBUNbEL65g==",
|
||||
"dependencies": {
|
||||
"@sqltools/formatter": "^1.2.5",
|
||||
"app-root-path": "^3.1.0",
|
||||
|
@ -11088,7 +10798,7 @@
|
|||
"dotenv": "^16.0.3",
|
||||
"glob": "^10.3.10",
|
||||
"mkdirp": "^2.1.3",
|
||||
"reflect-metadata": "^0.2.1",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"sha.js": "^2.4.11",
|
||||
"tslib": "^2.5.0",
|
||||
"uuid": "^9.0.0",
|
||||
|
@ -11100,7 +10810,7 @@
|
|||
"typeorm-ts-node-esm": "cli-ts-node-esm.js"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.13.0"
|
||||
"node": ">= 12.9.0"
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://opencollective.com/typeorm"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "card-drop",
|
||||
"version": "0.5.0",
|
||||
"version": "0.4.2",
|
||||
"main": "./dist/bot.js",
|
||||
"typings": "./dist",
|
||||
"scripts": {
|
||||
|
@ -26,12 +26,10 @@
|
|||
"funding": "https://ko-fi.com/vylpes",
|
||||
"dependencies": {
|
||||
"@discordjs/rest": "^2.0.0",
|
||||
"@types/clone-deep": "^4.0.4",
|
||||
"@types/express": "^4.17.20",
|
||||
"@types/jest": "^29.0.0",
|
||||
"@types/uuid": "^9.0.0",
|
||||
"body-parser": "^1.20.2",
|
||||
"clone-deep": "^4.0.1",
|
||||
"discord.js": "^14.3.0",
|
||||
"dotenv": "^16.0.0",
|
||||
"express": "^4.18.2",
|
||||
|
@ -41,7 +39,7 @@
|
|||
"minimatch": "9.0.3",
|
||||
"mysql": "^2.18.1",
|
||||
"ts-jest": "^29.0.0",
|
||||
"typeorm": "0.3.20"
|
||||
"typeorm": "0.3.19"
|
||||
},
|
||||
"resolutions": {},
|
||||
"devDependencies": {
|
||||
|
|
|
@ -3,8 +3,21 @@
|
|||
export PATH="$HOME/.yarn/bin:$PATH"
|
||||
export PATH="$HOME/.nodeuse/bin:$PATH"
|
||||
|
||||
cd ~/apps/card-drop/card-drop_prod
|
||||
docker compose --file docker-compose.prod.yml up -d
|
||||
sleep 10
|
||||
cp .prod.env .env
|
||||
pm2 restart card-drop_prod || pm2 start --name card-drop_prod dist/bot.js
|
||||
export BOT_TOKEN=$(cat $HOME/scripts/card-drop/prod_key.txt)
|
||||
|
||||
cd ~/apps/card-drop/card-drop_prod \
|
||||
&& git checkout main \
|
||||
&& git fetch \
|
||||
&& git pull \
|
||||
&& docker compose --file docker-compose.prod.yml down \
|
||||
&& (pm2 stop card-drop_prod || true) \
|
||||
&& (pm2 delete card-drop_prod || true) \
|
||||
&& cp .prod.env .env \
|
||||
&& npm run clean \
|
||||
&& npm ci \
|
||||
&& npm run build \
|
||||
&& docker compose --file docker-compose.prod.yml up -d \
|
||||
&& echo "Sleeping for 10 seconds to let database load..." \
|
||||
&& sleep 10 \
|
||||
&& npm run db:up \
|
||||
&& NODE_ENV=production pm2 start --name card-drop_prod dist/bot.js
|
|
@ -3,8 +3,21 @@
|
|||
export PATH="$HOME/.yarn/bin:$PATH"
|
||||
export PATH="$HOME/.nodeuse/bin:$PATH"
|
||||
|
||||
cd ~/apps/card-drop/card-drop_stage
|
||||
docker compose --file docker-compose.stage.yml up -d
|
||||
sleep 10
|
||||
cp .stage.env .env
|
||||
pm2 restart card-drop_stage || pm2 start --name card-drop_stage dist/bot.js
|
||||
export BOT_TOKEN=$(cat $HOME/scripts/card-drop/stage_key.txt)
|
||||
|
||||
cd ~/apps/card-drop/card-drop_stage \
|
||||
&& git checkout develop \
|
||||
&& git fetch \
|
||||
&& git pull \
|
||||
&& docker compose --file docker-compose.stage.yml down \
|
||||
&& (pm2 stop card-drop_stage || true) \
|
||||
&& (pm2 delete card-drop_stage || true) \
|
||||
&& cp .stage.env .env \
|
||||
&& npm run clean \
|
||||
&& npm ci \
|
||||
&& npm run build \
|
||||
&& docker compose --file docker-compose.stage.yml up -d \
|
||||
&& echo "Sleeping for 10 seconds to let database load..." \
|
||||
&& sleep 10 \
|
||||
&& npm run db:up \
|
||||
&& NODE_ENV=production pm2 start --name card-drop_stage dist/bot.js
|
|
@ -5,74 +5,37 @@ import { glob } from "glob";
|
|||
import { SeriesMetadata } from "../contracts/SeriesMetadata";
|
||||
import { CoreClient } from "../client/client";
|
||||
|
||||
export interface CardMetadataResult {
|
||||
IsSuccess: boolean;
|
||||
ErrorMessage?: string;
|
||||
}
|
||||
|
||||
export interface FindMetadataResult {
|
||||
IsSuccess: boolean;
|
||||
Result?: SeriesMetadata[];
|
||||
Error?: {
|
||||
File: string;
|
||||
Message: string;
|
||||
};
|
||||
}
|
||||
|
||||
export default class CardMetadataFunction {
|
||||
public static async Execute(overrideSafeMode: boolean = false): Promise<CardMetadataResult> {
|
||||
if (!overrideSafeMode && await Config.GetValue("safemode") == "true") return {
|
||||
IsSuccess: false,
|
||||
ErrorMessage: "Safe mode is on and not overridden",
|
||||
};
|
||||
public static async Execute(overrideSafeMode: boolean = false): Promise<boolean> {
|
||||
if (!overrideSafeMode && await Config.GetValue("safemode") == "true") return false;
|
||||
|
||||
const cardResult = await this.FindMetadataJSONs();
|
||||
try {
|
||||
CoreClient.Cards = await this.FindMetadataJSONs();
|
||||
|
||||
if (cardResult.IsSuccess) {
|
||||
CoreClient.Cards = cardResult.Result!;
|
||||
console.log(`Loaded ${CoreClient.Cards.flatMap(x => x.cards).length} cards to database`);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
return {
|
||||
IsSuccess: true,
|
||||
};
|
||||
await Config.SetValue("safemode", "true");
|
||||
return false;
|
||||
}
|
||||
|
||||
await Config.SetValue("safemode", "true");
|
||||
|
||||
return {
|
||||
IsSuccess: false,
|
||||
ErrorMessage: `${cardResult.Error!.File}: ${cardResult.Error!.Message}`,
|
||||
};
|
||||
return true;
|
||||
}
|
||||
|
||||
private static async FindMetadataJSONs(): Promise<FindMetadataResult> {
|
||||
private static async FindMetadataJSONs(): Promise<SeriesMetadata[]> {
|
||||
const res: SeriesMetadata[] = [];
|
||||
|
||||
const seriesJSONs = await glob(path.join(process.env.DATA_DIR!, "cards", "/**/*.json"));
|
||||
|
||||
for (const jsonPath of seriesJSONs) {
|
||||
try {
|
||||
console.log(`Reading file ${jsonPath}`);
|
||||
const jsonFile = readFileSync(jsonPath);
|
||||
const parsedJson: SeriesMetadata[] = JSON.parse(jsonFile.toString());
|
||||
console.log(`Reading file ${jsonPath}`);
|
||||
const jsonFile = readFileSync(jsonPath);
|
||||
const parsedJson: SeriesMetadata[] = JSON.parse(jsonFile.toString());
|
||||
|
||||
res.push(...parsedJson);
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
||||
return {
|
||||
IsSuccess: false,
|
||||
Error: {
|
||||
File: jsonPath,
|
||||
Message: `${e}`,
|
||||
}
|
||||
};
|
||||
}
|
||||
res.push(...parsedJson);
|
||||
}
|
||||
|
||||
return {
|
||||
IsSuccess: true,
|
||||
Result: res,
|
||||
};
|
||||
return res;
|
||||
}
|
||||
}
|
|
@ -4,27 +4,17 @@ import InventoryHelper from "../helpers/InventoryHelper";
|
|||
|
||||
export default class Inventory extends ButtonEvent {
|
||||
public override async execute(interaction: ButtonInteraction) {
|
||||
if (!interaction.guild) return;
|
||||
|
||||
const userid = interaction.customId.split(" ")[1];
|
||||
const page = interaction.customId.split(" ")[2];
|
||||
|
||||
const member = interaction.guild.members.cache.find(x => x.id == userid) || await interaction.guild.members.fetch(userid);
|
||||
|
||||
if (!member) {
|
||||
await interaction.reply("Unable to find user.");
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const embed = await InventoryHelper.GenerateInventoryPage(member.user.username, member.user.id, Number(page));
|
||||
const embed = await InventoryHelper.GenerateInventoryPage(interaction.user.username, userid, Number(page));
|
||||
|
||||
await interaction.update({
|
||||
embeds: [ embed.embed ],
|
||||
components: [ embed.row ],
|
||||
});
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} catch {
|
||||
await interaction.reply("No page for user found.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,10 +25,7 @@ export default class Gdrivesync extends Command {
|
|||
return;
|
||||
}
|
||||
|
||||
await interaction.reply({
|
||||
content: "Syncing, this might take a while...",
|
||||
ephemeral: true,
|
||||
});
|
||||
await interaction.reply("Syncing, this might take a while...");
|
||||
|
||||
CoreClient.AllowDrops = false;
|
||||
|
||||
|
@ -37,16 +34,12 @@ export default class Gdrivesync extends Command {
|
|||
await interaction.editReply(`Error while running sync command. Safe Mode has been activated. Code: ${error.code}`);
|
||||
await Config.SetValue("safemode", "true");
|
||||
} else {
|
||||
const result = await CardMetadataFunction.Execute(true);
|
||||
await CardMetadataFunction.Execute();
|
||||
|
||||
if (result.IsSuccess) {
|
||||
await interaction.editReply("Synced successfully.");
|
||||
await interaction.editReply("Synced successfully.");
|
||||
|
||||
CoreClient.AllowDrops = true;
|
||||
await Config.SetValue("safemode", "false");
|
||||
} else {
|
||||
await interaction.editReply(`Sync failed \`\`\`${result.ErrorMessage}\`\`\``);
|
||||
}
|
||||
CoreClient.AllowDrops = true;
|
||||
await Config.SetValue("safemode", "false");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,16 +12,11 @@ export default class Inventory extends Command {
|
|||
.addNumberOption(x =>
|
||||
x
|
||||
.setName("page")
|
||||
.setDescription("The page to start with"))
|
||||
.addUserOption(x =>
|
||||
x
|
||||
.setName("user")
|
||||
.setDescription("The user to view (Defaults to yourself)"));
|
||||
.setDescription("The page to start with"));
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
const page = interaction.options.get("page");
|
||||
const user = interaction.options.getUser("user") || interaction.user;
|
||||
|
||||
try {
|
||||
let pageNumber = 0;
|
||||
|
@ -30,7 +25,7 @@ export default class Inventory extends Command {
|
|||
pageNumber = Number(page.value) - 1;
|
||||
}
|
||||
|
||||
const embed = await InventoryHelper.GenerateInventoryPage(user.username, user.id, pageNumber);
|
||||
const embed = await InventoryHelper.GenerateInventoryPage(interaction.user.username, interaction.user.id, pageNumber);
|
||||
|
||||
await interaction.reply({
|
||||
embeds: [ embed.embed ],
|
||||
|
|
|
@ -1,77 +0,0 @@
|
|||
import { AttachmentBuilder, CommandInteraction, DiscordAPIError, SlashCommandBuilder } from "discord.js";
|
||||
import { Command } from "../type/command";
|
||||
import { CoreClient } from "../client/client";
|
||||
import { readFileSync } from "fs";
|
||||
import path from "path";
|
||||
import Inventory from "../database/entities/app/Inventory";
|
||||
import CardDropHelperMetadata from "../helpers/CardDropHelperMetadata";
|
||||
|
||||
export default class View extends Command {
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
this.CommandBuilder = new SlashCommandBuilder()
|
||||
.setName("view")
|
||||
.setDescription("View a specific command")
|
||||
.addStringOption(x =>
|
||||
x
|
||||
.setName("cardnumber")
|
||||
.setDescription("The card number to view")
|
||||
.setRequired(true));
|
||||
}
|
||||
|
||||
public override async execute(interaction: CommandInteraction) {
|
||||
const cardNumber = interaction.options.get("cardnumber");
|
||||
|
||||
if (!cardNumber || !cardNumber.value) {
|
||||
await interaction.reply("Card number is required.");
|
||||
return;
|
||||
}
|
||||
|
||||
const card = CoreClient.Cards
|
||||
.flatMap(x => x.cards)
|
||||
.find(x => x.id == cardNumber.value);
|
||||
|
||||
if (!card) {
|
||||
await interaction.reply("Card not found.");
|
||||
return;
|
||||
}
|
||||
|
||||
const series = CoreClient.Cards
|
||||
.find(x => x.cards.includes(card))!;
|
||||
|
||||
let image: Buffer;
|
||||
const imageFileName = card.path.split("/").pop()!;
|
||||
|
||||
try {
|
||||
image = readFileSync(path.join(process.env.DATA_DIR!, "cards", card.path));
|
||||
} catch {
|
||||
await interaction.reply(`Unable to fetch image for card ${card.id}.`);
|
||||
return;
|
||||
}
|
||||
|
||||
await interaction.deferReply();
|
||||
|
||||
const attachment = new AttachmentBuilder(image, { name: imageFileName });
|
||||
|
||||
const inventory = await Inventory.FetchOneByCardNumberAndUserId(interaction.user.id, card.id);
|
||||
const quantityClaimed = inventory ? inventory.Quantity : 0;
|
||||
|
||||
const embed = CardDropHelperMetadata.GenerateDropEmbed({ card, series }, quantityClaimed, imageFileName);
|
||||
|
||||
try {
|
||||
await interaction.editReply({
|
||||
embeds: [ embed ],
|
||||
files: [ attachment ],
|
||||
});
|
||||
} 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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,5 @@
|
|||
export default class EmbedColours {
|
||||
public static readonly Ok = 0x3050ba;
|
||||
public static readonly Error = 0xff0000;
|
||||
public static readonly Grey = 0xd3d3d3;
|
||||
public static readonly BronzeCard = 0xcd7f32;
|
||||
public static readonly SilverCard = 0xc0c0c0;
|
||||
|
|
|
@ -63,7 +63,7 @@ export default class CardDropHelperMetadata {
|
|||
return new EmbedBuilder()
|
||||
.setTitle(drop.card.name)
|
||||
.setDescription(description)
|
||||
.setFooter({ text: `${CardRarityToString(drop.card.type)} · ${drop.card.id}` })
|
||||
.setFooter({ text: CardRarityToString(drop.card.type) })
|
||||
.setColor(CardRarityToColour(drop.card.type))
|
||||
.setImage(`attachment://${imageFileName}`);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ import Inventory from "../database/entities/app/Inventory";
|
|||
import { CoreClient } from "../client/client";
|
||||
import EmbedColours from "../constants/EmbedColours";
|
||||
import { CardRarity, CardRarityToString } from "../constants/CardRarity";
|
||||
import cloneDeep from "clone-deep";
|
||||
|
||||
interface InventoryPage {
|
||||
id: number,
|
||||
|
@ -25,9 +24,7 @@ export default class InventoryHelper {
|
|||
|
||||
const inventory = await Inventory.FetchAllByUserId(userid);
|
||||
|
||||
const clientCards = cloneDeep(CoreClient.Cards);
|
||||
|
||||
const allSeriesClaimed = clientCards
|
||||
const allSeriesClaimed = CoreClient.Cards
|
||||
.sort((a, b) => a.id - b.id)
|
||||
.filter(x => {
|
||||
x.cards = x.cards
|
||||
|
|
|
@ -8,7 +8,6 @@ import Gdrivesync from "./commands/gdrivesync";
|
|||
import Give from "./commands/give";
|
||||
import Inventory from "./commands/inventory";
|
||||
import Resync from "./commands/resync";
|
||||
import View from "./commands/view";
|
||||
|
||||
// Test Command Imports
|
||||
import Dropnumber from "./commands/stage/dropnumber";
|
||||
|
@ -28,7 +27,6 @@ export default class Registry {
|
|||
CoreClient.RegisterCommand("give", new Give());
|
||||
CoreClient.RegisterCommand("inventory", new Inventory());
|
||||
CoreClient.RegisterCommand("resync", new Resync());
|
||||
CoreClient.RegisterCommand("view", new View());
|
||||
|
||||
// Test Commands
|
||||
CoreClient.RegisterCommand("dropnumber", new Dropnumber(), Environment.Test);
|
||||
|
|
Loading…
Reference in a new issue