Moved to zod

This commit is contained in:
2024-12-24 22:40:03 +01:00
parent 3797fa1c47
commit 5d81665cf8
6 changed files with 188 additions and 70 deletions

View File

@@ -52,7 +52,8 @@
"ioredis": "^5.4.1",
"ms": "^2.1.3",
"postgres": "^3.4.5",
"pretty-ms": "^9.2.0"
"pretty-ms": "^9.2.0",
"zod": "^3.24.1"
},
"devDependencies": {
"@eslint/eslintrc": "^3.2.0",
@@ -68,6 +69,7 @@
"eslint": "^9.16.0",
"eslint-plugin-drizzle": "^0.2.3",
"globals": "^15.13.0",
"nodemon": "^3.1.9",
"tsx": "^4.19.2",
"typescript": "^5.7.2"
},

153
pnpm-lock.yaml generated
View File

@@ -64,6 +64,9 @@ importers:
pretty-ms:
specifier: ^9.2.0
version: 9.2.0
zod:
specifier: ^3.24.1
version: 3.24.1
devDependencies:
'@eslint/eslintrc':
specifier: ^3.2.0
@@ -104,6 +107,9 @@ importers:
globals:
specifier: ^15.13.0
version: 15.13.0
nodemon:
specifier: ^3.1.9
version: 3.1.9
tsx:
specifier: ^4.19.2
version: 4.19.2
@@ -1123,6 +1129,10 @@ packages:
resolution: {integrity: sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==}
engines: {node: '>=8'}
anymatch@3.1.3:
resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
engines: {node: '>= 8'}
aproba@2.0.0:
resolution: {integrity: sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==}
@@ -1163,6 +1173,10 @@ packages:
resolution: {integrity: sha512-nk5wEsP4RiKjG+vF+uG8lFsEn4d7Y6FVDamzzftSunXOoOcOOkzcWdKVlGgFFwlUQCj63SgnUkLLGF8v7lufhw==}
engines: {node: '>=12'}
binary-extensions@2.3.0:
resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==}
engines: {node: '>=8'}
bindings@1.5.0:
resolution: {integrity: sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==}
@@ -1215,6 +1229,10 @@ packages:
resolution: {integrity: sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==}
engines: {node: ^12.17.0 || ^14.13 || >=16.0.0}
chokidar@3.6.0:
resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==}
engines: {node: '>= 8.10.0'}
chokidar@4.0.1:
resolution: {integrity: sha512-n8enUVCED/KVRQlab1hr3MVpcVMvxtZjmEa956u+4YijlmQED223XMSYj2tLuKvr4jcCTzNNMpQDUer72MMmzA==}
engines: {node: '>= 14.16.0'}
@@ -1742,6 +1760,10 @@ packages:
graphemer@1.4.0:
resolution: {integrity: sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==}
has-flag@3.0.0:
resolution: {integrity: sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw==}
engines: {node: '>=4'}
has-flag@4.0.0:
resolution: {integrity: sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==}
engines: {node: '>=8'}
@@ -1785,6 +1807,9 @@ packages:
ieee754@1.2.1:
resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==}
ignore-by-default@1.0.1:
resolution: {integrity: sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==}
ignore@5.3.2:
resolution: {integrity: sha512-hsBTNUqQTDwkWtcdYI2i06Y/nUBEsNEDJKjWdigLvegy8kDuJAS8uRlpkkcQpyEXL0Z/pjDy5HBmMjRCJ2gq+g==}
engines: {node: '>= 4'}
@@ -1825,6 +1850,10 @@ packages:
resolution: {integrity: sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==}
engines: {node: '>= 12'}
is-binary-path@2.1.0:
resolution: {integrity: sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==}
engines: {node: '>=8'}
is-extglob@2.1.1:
resolution: {integrity: sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==}
engines: {node: '>=0.10.0'}
@@ -2069,11 +2098,20 @@ packages:
node-html-parser@6.1.13:
resolution: {integrity: sha512-qIsTMOY4C/dAa5Q5vsobRpOOvPfC4pB61UVW2uSwZNUp0QU/jCekTal1vMmbO0DgdHeLUJpv/ARmDqErVxA3Sg==}
nodemon@3.1.9:
resolution: {integrity: sha512-hdr1oIb2p6ZSxu3PB2JWWYS7ZQ0qvaZsc3hK8DR8f02kRzc8rjYmxAIvdz+aYC+8F2IjNaB7HMcSDg8nQpJxyg==}
engines: {node: '>=10'}
hasBin: true
nopt@5.0.0:
resolution: {integrity: sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==}
engines: {node: '>=6'}
hasBin: true
normalize-path@3.0.0:
resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==}
engines: {node: '>=0.10.0'}
normalize-url@8.0.1:
resolution: {integrity: sha512-IO9QvjUMWxPQQhs60oOu10CRkWCiZzSUkzbXGGV9pviYl1fXYcvkzQ5jV9z8Y6un8ARoVRl4EtC6v6jNqbaJ/w==}
engines: {node: '>=14.16'}
@@ -2284,6 +2322,9 @@ packages:
proxy-from-env@1.1.0:
resolution: {integrity: sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==}
pstree.remy@1.1.8:
resolution: {integrity: sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==}
pump@3.0.2:
resolution: {integrity: sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==}
@@ -2313,6 +2354,10 @@ packages:
resolution: {integrity: sha512-ePeK6cc1EcKLEhJFt/AebMCLL+GgSKhuygrZ/GLaKZYEecIgIECf4UaUuaByiGtzckwR4ain9VzUh95T1exYGw==}
engines: {node: '>=8'}
readdirp@3.6.0:
resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==}
engines: {node: '>=8.10.0'}
readdirp@4.0.2:
resolution: {integrity: sha512-yDMz9g+VaZkqBYS/ozoBJwaBhTbZo3UNYQHNRw1D3UFQB8oHB4uS/tAODO+ZLjGWmUbKnIlOWO+aaIiAxrUWHA==}
engines: {node: '>= 14.16.0'}
@@ -2401,6 +2446,10 @@ packages:
simple-get@4.0.1:
resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==}
simple-update-notifier@2.0.0:
resolution: {integrity: sha512-a2B9Y0KlNXl9u/vsW6sTIu9vGEpfKu2wRV6l1H3XEas/0gUIzGzBoP/IouTcUQbm9JWZLH3COxyn03TYlFax6w==}
engines: {node: '>=10'}
slash@3.0.0:
resolution: {integrity: sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q==}
engines: {node: '>=8'}
@@ -2501,6 +2550,10 @@ packages:
resolution: {integrity: sha512-FhwotcEqjr241ZbjFzjlIYg6c5/L/s4yBGWSMvJ9UoExiSqL+FnFA/CaeZx17WGaZMS/4SOZp8wH18jSS4R4lw==}
engines: {node: '>=16'}
supports-color@5.5.0:
resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==}
engines: {node: '>=4'}
supports-color@7.2.0:
resolution: {integrity: sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==}
engines: {node: '>=8'}
@@ -2540,6 +2593,10 @@ packages:
resolution: {integrity: sha512-lbDrTLVsHhOMljPscd0yitpozq7Ga2M5Cvez5AjGg8GASBjtt6iERCAJ93yommPmz62fb45oFIXHEZ3u9bfJEA==}
engines: {node: '>=14.16'}
touch@3.1.1:
resolution: {integrity: sha512-r0eojU4bI8MnHr8c5bNo7lJDdI2qXlWWJk6a9EAFG7vbhTjElYhBVS3/miuE0uOuoLdb8Mc/rVfsmm6eo5o9GA==}
hasBin: true
tr46@0.0.3:
resolution: {integrity: sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==}
@@ -2579,6 +2636,9 @@ packages:
unbzip2-stream@1.4.3:
resolution: {integrity: sha512-mlExGW4w71ebDJviH16lQLtZS32VKqsSfk80GCfUlwT/4/hNRFsoscrF/c++9xinkMzECL1uL9DDwXqFWkruPg==}
undefsafe@2.0.5:
resolution: {integrity: sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA==}
undici-types@6.20.0:
resolution: {integrity: sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==}
@@ -2667,6 +2727,9 @@ packages:
youtubei.js@12.0.0:
resolution: {integrity: sha512-pGmVb1I9b2gseqmuMx+BCajzVUi04+r+8zxj4Fk/iQaGQGvBCbY87Tu9mdvEgIQYTkkb4Fza7GZGrH9AjYNbrw==}
zod@3.24.1:
resolution: {integrity: sha512-muH7gBL9sI1nciMZV67X5fTKKBLtwpZ5VBp1vsOQzj1MhrBZ4wlVCm3gedKZWLp0Oyel8sIGfeiz54Su+OVT+A==}
snapshots:
'@bufbuild/protobuf@2.1.0': {}
@@ -2999,7 +3062,7 @@ snapshots:
'@eslint/config-array@0.19.1':
dependencies:
'@eslint/object-schema': 2.1.5
debug: 4.3.7
debug: 4.3.7(supports-color@5.5.0)
minimatch: 3.1.2
transitivePeerDependencies:
- supports-color
@@ -3011,7 +3074,7 @@ snapshots:
'@eslint/eslintrc@3.2.0':
dependencies:
ajv: 6.12.6
debug: 4.3.7
debug: 4.3.7(supports-color@5.5.0)
espree: 10.2.0
globals: 14.0.0
ignore: 5.3.2
@@ -3293,7 +3356,7 @@ snapshots:
'@typescript-eslint/types': 8.17.0
'@typescript-eslint/typescript-estree': 8.17.0(typescript@5.7.2)
'@typescript-eslint/visitor-keys': 8.17.0
debug: 4.3.7
debug: 4.3.7(supports-color@5.5.0)
eslint: 9.16.0
optionalDependencies:
typescript: 5.7.2
@@ -3309,7 +3372,7 @@ snapshots:
dependencies:
'@typescript-eslint/typescript-estree': 8.17.0(typescript@5.7.2)
'@typescript-eslint/utils': 8.17.0(eslint@9.16.0)(typescript@5.7.2)
debug: 4.3.7
debug: 4.3.7(supports-color@5.5.0)
eslint: 9.16.0
ts-api-utils: 1.3.0(typescript@5.7.2)
optionalDependencies:
@@ -3323,7 +3386,7 @@ snapshots:
dependencies:
'@typescript-eslint/types': 8.17.0
'@typescript-eslint/visitor-keys': 8.17.0
debug: 4.3.7
debug: 4.3.7(supports-color@5.5.0)
fast-glob: 3.3.2
is-glob: 4.0.3
minimatch: 9.0.5
@@ -3440,7 +3503,7 @@ snapshots:
agent-base@6.0.2:
dependencies:
debug: 4.3.7
debug: 4.3.7(supports-color@5.5.0)
transitivePeerDependencies:
- supports-color
optional: true
@@ -3474,6 +3537,11 @@ snapshots:
dependencies:
color-convert: 2.0.1
anymatch@3.1.3:
dependencies:
normalize-path: 3.0.0
picomatch: 2.3.1
aproba@2.0.0:
optional: true
@@ -3517,6 +3585,8 @@ snapshots:
execa: 5.1.1
find-versions: 5.1.0
binary-extensions@2.3.0: {}
bindings@1.5.0:
dependencies:
file-uri-to-path: 1.0.0
@@ -3598,6 +3668,18 @@ snapshots:
chalk@5.3.0: {}
chokidar@3.6.0:
dependencies:
anymatch: 3.1.3
braces: 3.0.3
glob-parent: 5.1.2
is-binary-path: 2.1.0
is-glob: 4.0.3
normalize-path: 3.0.0
readdirp: 3.6.0
optionalDependencies:
fsevents: 2.3.3
chokidar@4.0.1:
dependencies:
readdirp: 4.0.2
@@ -3662,9 +3744,11 @@ snapshots:
data-uri-to-buffer@4.0.1: {}
debug@4.3.7:
debug@4.3.7(supports-color@5.5.0):
dependencies:
ms: 2.1.3
optionalDependencies:
supports-color: 5.5.0
decompress-response@6.0.0:
dependencies:
@@ -3827,7 +3911,7 @@ snapshots:
esbuild-register@3.6.0(esbuild@0.19.12):
dependencies:
debug: 4.3.7
debug: 4.3.7(supports-color@5.5.0)
esbuild: 0.19.12
transitivePeerDependencies:
- supports-color
@@ -3944,7 +4028,7 @@ snapshots:
ajv: 6.12.6
chalk: 4.1.2
cross-spawn: 7.0.6
debug: 4.3.7
debug: 4.3.7(supports-color@5.5.0)
escape-string-regexp: 4.0.0
eslint-scope: 8.2.0
eslint-visitor-keys: 4.2.0
@@ -4184,6 +4268,8 @@ snapshots:
graphemer@1.4.0: {}
has-flag@3.0.0: {}
has-flag@4.0.0: {}
has-unicode@2.0.1:
@@ -4199,7 +4285,7 @@ snapshots:
dependencies:
'@tootallnate/once': 1.1.2
agent-base: 6.0.2
debug: 4.3.7
debug: 4.3.7(supports-color@5.5.0)
transitivePeerDependencies:
- supports-color
optional: true
@@ -4212,7 +4298,7 @@ snapshots:
https-proxy-agent@5.0.1:
dependencies:
agent-base: 6.0.2
debug: 4.3.7
debug: 4.3.7(supports-color@5.5.0)
transitivePeerDependencies:
- supports-color
optional: true
@@ -4231,6 +4317,8 @@ snapshots:
ieee754@1.2.1: {}
ignore-by-default@1.0.1: {}
ignore@5.3.2: {}
import-fresh@3.3.0:
@@ -4265,7 +4353,7 @@ snapshots:
dependencies:
'@ioredis/commands': 1.2.0
cluster-key-slot: 1.1.2
debug: 4.3.7
debug: 4.3.7(supports-color@5.5.0)
denque: 2.1.0
lodash.defaults: 4.2.0
lodash.isarguments: 3.1.0
@@ -4281,6 +4369,10 @@ snapshots:
sprintf-js: 1.1.3
optional: true
is-binary-path@2.1.0:
dependencies:
binary-extensions: 2.3.0
is-extglob@2.1.1: {}
is-fullwidth-code-point@3.0.0:
@@ -4532,11 +4624,26 @@ snapshots:
css-select: 5.1.0
he: 1.2.0
nodemon@3.1.9:
dependencies:
chokidar: 3.6.0
debug: 4.3.7(supports-color@5.5.0)
ignore-by-default: 1.0.1
minimatch: 3.1.2
pstree.remy: 1.1.8
semver: 7.6.3
simple-update-notifier: 2.0.0
supports-color: 5.5.0
touch: 3.1.1
undefsafe: 2.0.5
nopt@5.0.0:
dependencies:
abbrev: 1.1.1
optional: true
normalize-path@3.0.0: {}
normalize-url@8.0.1: {}
npm-run-path@4.0.1:
@@ -4740,6 +4847,8 @@ snapshots:
proxy-from-env@1.1.0: {}
pstree.remy@1.1.8: {}
pump@3.0.2:
dependencies:
end-of-stream: 1.4.4
@@ -4772,6 +4881,10 @@ snapshots:
dependencies:
readable-stream: 3.6.2
readdirp@3.6.0:
dependencies:
picomatch: 2.3.1
readdirp@4.0.2: {}
redis-errors@1.2.0: {}
@@ -4848,6 +4961,10 @@ snapshots:
simple-concat: 1.0.1
optional: true
simple-update-notifier@2.0.0:
dependencies:
semver: 7.6.3
slash@3.0.0: {}
smart-buffer@4.2.0:
@@ -4856,7 +4973,7 @@ snapshots:
socks-proxy-agent@6.2.1:
dependencies:
agent-base: 6.0.2
debug: 4.3.7
debug: 4.3.7(supports-color@5.5.0)
socks: 2.8.3
transitivePeerDependencies:
- supports-color
@@ -4968,6 +5085,10 @@ snapshots:
'@tokenizer/token': 0.3.0
peek-readable: 5.3.1
supports-color@5.5.0:
dependencies:
has-flag: 3.0.0
supports-color@7.2.0:
dependencies:
has-flag: 4.0.0
@@ -5027,6 +5148,8 @@ snapshots:
'@tokenizer/token': 0.3.0
ieee754: 1.2.1
touch@3.1.1: {}
tr46@0.0.3(patch_hash=bpj6gcw6zugqpvk6vn5cnxkdsq): {}
ts-api-utils@1.3.0(typescript@5.7.2):
@@ -5062,6 +5185,8 @@ snapshots:
buffer: 5.7.1
through: 2.3.8
undefsafe@2.0.5: {}
undici-types@6.20.0: {}
undici@5.28.4:
@@ -5136,3 +5261,5 @@ snapshots:
jintr: 3.1.0
tslib: 2.7.0
undici: 5.28.4
zod@3.24.1: {}

View File

@@ -1,19 +0,0 @@
interface ProdEnv {
token: string
dev: string
hypixelapikey: string
redisURI: string
postgresURI: string
}
interface DevEnv {
devtoken: string
clientid: string
devid: string
guildid: string
}
export default interface IEnv {
prod: ProdEnv
dev: DevEnv
}

View File

@@ -6,9 +6,8 @@ import IEvent from "./IEvent"
import IModal from "./IModal"
import ICron from "./ICron"
import IEnv from "./IEnv"
import { IGuild, IGuildData } from "./IGuild"
import { IPlayer, IPlayerData } from "./IPlayer"
export { IAutocomplete, IButton, ICommand, IContextMenu, ICron, IEnv, IEvent, IGuild, IGuildData, IModal, IPlayer, IPlayerData }
export { IAutocomplete, IButton, ICommand, IContextMenu, ICron, IEvent, IGuild, IGuildData, IModal, IPlayer, IPlayerData }

View File

@@ -1,20 +1,49 @@
import { IEnv } from "~/interfaces"
// import { IEnv } from "~/interfaces"
import { z } from "zod"
import { MissingEnvVarsError } from "./Classes.js"
// import "dotenv/config"
const env: IEnv = {
prod: {
token: process.env.TOKEN!,
dev: process.env.DEV!,
hypixelapikey: process.env.HYPIXELAPIKEY!,
redisURI: process.env.REDISURI!,
postgresURI: process.env.POSTGRESURI!
},
dev: {
devtoken: process.env.DEVTOKEN!,
clientid: process.env.CLIENTID!,
devid: process.env.DEVID!,
guildid: process.env.GUILDID!
}
const prodEnvSchema = z.object({
token: z.string(),
dev: z.string(),
hypixelapikey: z.string(),
redisURI: z.string(),
postgresURI: z.string()
})
const devEnvSchema = z.object({
devtoken: z.string(),
clientid: z.string(),
devid: z.string(),
guildid: z.string()
})
const parsedProdEnv = prodEnvSchema.safeParse({
token: process.env.TOKEN,
dev: process.env.DEV,
hypixelapikey: process.env.HYPIXELAPIKEY,
redisURI: process.env.REDISURI,
postgresURI: process.env.POSTGRESURI
})
const parsedDevEnv = devEnvSchema.safeParse({
devtoken: process.env.DEVTOKEN,
clientid: process.env.CLIENTID,
devid: process.env.DEVID,
guildid: process.env.GUILDID
})
if (!parsedProdEnv.success) {
throw new MissingEnvVarsError(parsedProdEnv.error.errors[0].message)
}
if (!parsedDevEnv.success && process.env.NODE_ENV === "dev") {
throw new MissingEnvVarsError(parsedDevEnv.error.errors[0].message)
}
const env = {
prod: parsedProdEnv.data,
dev: parsedDevEnv.data
} as { prod: z.infer<typeof prodEnvSchema>, dev: z.infer<typeof devEnvSchema> }
export default env

View File

@@ -3,7 +3,6 @@ import { YoutubeiExtractor } from "discord-player-youtubei"
import { Redis } from "ioredis"
import { ExtendedClient as Client } from "~/utils/Client.js"
import env from "~/utils/Env.js"
import { MissingEnvVarsError } from "./Classes.js"
import loadAllEvents from "./Events/loadevents.js"
import { log } from "./Logger.js"
@@ -20,7 +19,6 @@ if (process.env.NODE_ENV === "dev" && process.env.TYPESCRIPT === "true") {
class Illegitimate {
async start() {
await this.init()
await loadAllEvents(client, ft)
// await player.extractors.loadDefault()
await player.extractors.loadDefault(ext => ext != "YouTubeExtractor")
@@ -36,24 +34,6 @@ class Illegitimate {
})
}
private async init() {
const prodValues = env.prod
const devValues = env.dev
if (process.env.NODE_ENV === "dev") {
for (const [key, value] of Object.entries(devValues)) {
if (!value) throw new MissingEnvVarsError(`No ${key} specified`)
}
for (const [key, value] of Object.entries(prodValues)) {
if (!value) throw new MissingEnvVarsError(`No ${key} specified`)
}
} else {
for (const [key, value] of Object.entries(prodValues)) {
if (!value) throw new MissingEnvVarsError(`No ${key} specified`)
}
}
}
private loadMethods() {
String.prototype.removeIndents = function(this: string) {
return this.replace(/^ */gm, "")