mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
Merge branch 'ZeppelinBot:master' into master
This commit is contained in:
commit
c85d87209c
10 changed files with 119 additions and 123 deletions
155
backend/package-lock.json
generated
155
backend/package-lock.json
generated
|
@ -13,7 +13,7 @@
|
|||
"cors": "^2.8.5",
|
||||
"cross-env": "^5.2.0",
|
||||
"deep-diff": "^1.0.2",
|
||||
"discord.js": "^14.8.0",
|
||||
"discord.js": "^14.9.0",
|
||||
"dotenv": "^4.0.0",
|
||||
"emoji-regex": "^8.0.0",
|
||||
"erlpack": "github:discord/erlpack",
|
||||
|
@ -23,7 +23,7 @@
|
|||
"humanize-duration": "^3.15.0",
|
||||
"io-ts": "^2.0.0",
|
||||
"js-yaml": "^3.13.1",
|
||||
"knub": "^32.0.0-next.6",
|
||||
"knub": "^32.0.0-next.8",
|
||||
"knub-command-manager": "^9.1.0",
|
||||
"last-commit-log": "^2.1.0",
|
||||
"lodash.chunk": "^4.2.0",
|
||||
|
@ -200,14 +200,14 @@
|
|||
}
|
||||
},
|
||||
"node_modules/@discordjs/builders": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.5.0.tgz",
|
||||
"integrity": "sha512-7XxT78mnNBPigHn2y6KAXkicxIBFtZREGWaRZ249EC1l6gBUEP8IyVY5JTciIjJArxkF+tg675aZvsTNTKBpmA==",
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.6.0.tgz",
|
||||
"integrity": "sha512-fiN66GV7ArEXAzIdu/pZ3F08YGpunjcdhCePAxnGoVs1LZDD7ek08rgCPWicxvn7BOgfyPq/rVmDzpAGZgRxvg==",
|
||||
"dependencies": {
|
||||
"@discordjs/formatters": "^0.2.0",
|
||||
"@discordjs/util": "^0.2.0",
|
||||
"@sapphire/shapeshift": "^3.8.1",
|
||||
"discord-api-types": "^0.37.35",
|
||||
"discord-api-types": "^0.37.37",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"ts-mixer": "^6.0.3",
|
||||
"tslib": "^2.5.0"
|
||||
|
@ -216,15 +216,7 @@
|
|||
"node": ">=16.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/collection": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.4.0.tgz",
|
||||
"integrity": "sha512-hiOJyk2CPFf1+FL3a4VKCuu1f448LlROVuu8nLz1+jCOAPokUcdFAV+l4pd3B3h6uJlJQSASoZzrdyNdjdtfzQ==",
|
||||
"engines": {
|
||||
"node": ">=16.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/formatters": {
|
||||
"node_modules/@discordjs/builders/node_modules/@discordjs/formatters": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.2.0.tgz",
|
||||
"integrity": "sha512-vn4oMSXuMZUm8ITqVOtvE7/fMMISj4cI5oLsR09PEQXHKeKDAMLltG/DWeeIs7Idfy6V8Fk3rn1e69h7NfzuNA==",
|
||||
|
@ -235,19 +227,38 @@
|
|||
"node": ">=16.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/rest": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-1.6.0.tgz",
|
||||
"integrity": "sha512-HGvqNCZ5Z5j0tQHjmT1lFvE5ETO4hvomJ1r0cbnpC1zM23XhCpZ9wgTCiEmaxKz05cyf2CI9p39+9LL+6Yz1bA==",
|
||||
"node_modules/@discordjs/collection": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.5.0.tgz",
|
||||
"integrity": "sha512-suyVndkEAAWrGxyw/CPGdtXoRRU6AUNkibtnbJevQzpelkJh3Q1gQqWDpqf5i39CnAn5+LrN0YS+cULeEjq2Yw==",
|
||||
"engines": {
|
||||
"node": ">=16.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/formatters": {
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.3.0.tgz",
|
||||
"integrity": "sha512-Fc4MomalbP8HMKEMor3qUiboAKDtR7PSBoPjwm7WYghVRwgJlj5WYvUsriLsxeKk8+Qq2oy+HJlGTUkGvX0YnA==",
|
||||
"dependencies": {
|
||||
"@discordjs/collection": "^1.4.0",
|
||||
"discord-api-types": "^0.37.37"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.9.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@discordjs/rest": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-1.7.0.tgz",
|
||||
"integrity": "sha512-r2HzmznRIo8IDGYBWqQfkEaGN1LrFfWQd3dSyC4tOpMU8nuVvFUEw6V/lwnG44jyOq+vgyDny2fxeUDMt9I4aQ==",
|
||||
"dependencies": {
|
||||
"@discordjs/collection": "^1.5.0",
|
||||
"@discordjs/util": "^0.2.0",
|
||||
"@sapphire/async-queue": "^1.5.0",
|
||||
"@sapphire/snowflake": "^3.4.0",
|
||||
"discord-api-types": "^0.37.35",
|
||||
"discord-api-types": "^0.37.37",
|
||||
"file-type": "^18.2.1",
|
||||
"tslib": "^2.5.0",
|
||||
"undici": "^5.20.0"
|
||||
"undici": "^5.21.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.9.0"
|
||||
|
@ -1840,23 +1851,23 @@
|
|||
"integrity": "sha512-LDMBKzl/zbvHO/yCzno5hevuA6lFIXJwdKSJZQrB+1ToDpFfN9thK+xxgZNR4aVkI7GHRDja0p4Sl2oYVPnHYg=="
|
||||
},
|
||||
"node_modules/discord.js": {
|
||||
"version": "14.8.0",
|
||||
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.8.0.tgz",
|
||||
"integrity": "sha512-UOxYtc/YnV7jAJ2gISluJyYeBw4e+j8gWn+IoqG8unaHAVuvZ13DdYN0M1f9fbUgUvSarV798inIrYFtDNDjwQ==",
|
||||
"version": "14.9.0",
|
||||
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.9.0.tgz",
|
||||
"integrity": "sha512-ygGms5xP4hG+QrrY9k7d/OYCzMltSMtdl/2Snzq/nLCiZo+Sna91Ulv9l0+B5Jd/Czcq37B7wJAnmja7GOa+bg==",
|
||||
"dependencies": {
|
||||
"@discordjs/builders": "^1.5.0",
|
||||
"@discordjs/collection": "^1.4.0",
|
||||
"@discordjs/formatters": "^0.2.0",
|
||||
"@discordjs/rest": "^1.6.0",
|
||||
"@discordjs/builders": "^1.6.0",
|
||||
"@discordjs/collection": "^1.5.0",
|
||||
"@discordjs/formatters": "^0.3.0",
|
||||
"@discordjs/rest": "^1.7.0",
|
||||
"@discordjs/util": "^0.2.0",
|
||||
"@sapphire/snowflake": "^3.4.0",
|
||||
"@types/ws": "^8.5.4",
|
||||
"discord-api-types": "^0.37.35",
|
||||
"discord-api-types": "^0.37.37",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"lodash.snakecase": "^4.1.1",
|
||||
"tslib": "^2.5.0",
|
||||
"undici": "^5.20.0",
|
||||
"ws": "^8.12.1"
|
||||
"undici": "^5.21.0",
|
||||
"ws": "^8.13.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=16.9.0"
|
||||
|
@ -3042,11 +3053,11 @@
|
|||
}
|
||||
},
|
||||
"node_modules/knub": {
|
||||
"version": "32.0.0-next.6",
|
||||
"resolved": "https://registry.npmjs.org/knub/-/knub-32.0.0-next.6.tgz",
|
||||
"integrity": "sha512-rrpNM1RyVNhTFradUNTc+0MC3JeYHvlVs9+v7MsdozR6gryIIDr8Tf2+pt749MpFW+ZGNXBMR/iIPVIp+6oPSA==",
|
||||
"version": "32.0.0-next.8",
|
||||
"resolved": "https://registry.npmjs.org/knub/-/knub-32.0.0-next.8.tgz",
|
||||
"integrity": "sha512-/T152tJUQFD+aAMg72BbUjfhy/tofnF5TBYTc7vR2KLssh36cOlpZs7BSPg+EDreg9S8xhAMyCDwkm8AQyRHOg==",
|
||||
"dependencies": {
|
||||
"discord.js": "^14.8.0",
|
||||
"discord.js": "^14.9.0",
|
||||
"knub-command-manager": "^9.1.0",
|
||||
"ts-essentials": "^9",
|
||||
"zod": "^3.19.1"
|
||||
|
@ -6118,45 +6129,55 @@
|
|||
}
|
||||
},
|
||||
"@discordjs/builders": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.5.0.tgz",
|
||||
"integrity": "sha512-7XxT78mnNBPigHn2y6KAXkicxIBFtZREGWaRZ249EC1l6gBUEP8IyVY5JTciIjJArxkF+tg675aZvsTNTKBpmA==",
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-1.6.0.tgz",
|
||||
"integrity": "sha512-fiN66GV7ArEXAzIdu/pZ3F08YGpunjcdhCePAxnGoVs1LZDD7ek08rgCPWicxvn7BOgfyPq/rVmDzpAGZgRxvg==",
|
||||
"requires": {
|
||||
"@discordjs/formatters": "^0.2.0",
|
||||
"@discordjs/util": "^0.2.0",
|
||||
"@sapphire/shapeshift": "^3.8.1",
|
||||
"discord-api-types": "^0.37.35",
|
||||
"discord-api-types": "^0.37.37",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"ts-mixer": "^6.0.3",
|
||||
"tslib": "^2.5.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@discordjs/formatters": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.2.0.tgz",
|
||||
"integrity": "sha512-vn4oMSXuMZUm8ITqVOtvE7/fMMISj4cI5oLsR09PEQXHKeKDAMLltG/DWeeIs7Idfy6V8Fk3rn1e69h7NfzuNA==",
|
||||
"requires": {
|
||||
"discord-api-types": "^0.37.35"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"@discordjs/collection": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.4.0.tgz",
|
||||
"integrity": "sha512-hiOJyk2CPFf1+FL3a4VKCuu1f448LlROVuu8nLz1+jCOAPokUcdFAV+l4pd3B3h6uJlJQSASoZzrdyNdjdtfzQ=="
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-1.5.0.tgz",
|
||||
"integrity": "sha512-suyVndkEAAWrGxyw/CPGdtXoRRU6AUNkibtnbJevQzpelkJh3Q1gQqWDpqf5i39CnAn5+LrN0YS+cULeEjq2Yw=="
|
||||
},
|
||||
"@discordjs/formatters": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.2.0.tgz",
|
||||
"integrity": "sha512-vn4oMSXuMZUm8ITqVOtvE7/fMMISj4cI5oLsR09PEQXHKeKDAMLltG/DWeeIs7Idfy6V8Fk3rn1e69h7NfzuNA==",
|
||||
"version": "0.3.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/formatters/-/formatters-0.3.0.tgz",
|
||||
"integrity": "sha512-Fc4MomalbP8HMKEMor3qUiboAKDtR7PSBoPjwm7WYghVRwgJlj5WYvUsriLsxeKk8+Qq2oy+HJlGTUkGvX0YnA==",
|
||||
"requires": {
|
||||
"discord-api-types": "^0.37.35"
|
||||
"discord-api-types": "^0.37.37"
|
||||
}
|
||||
},
|
||||
"@discordjs/rest": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-1.6.0.tgz",
|
||||
"integrity": "sha512-HGvqNCZ5Z5j0tQHjmT1lFvE5ETO4hvomJ1r0cbnpC1zM23XhCpZ9wgTCiEmaxKz05cyf2CI9p39+9LL+6Yz1bA==",
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-1.7.0.tgz",
|
||||
"integrity": "sha512-r2HzmznRIo8IDGYBWqQfkEaGN1LrFfWQd3dSyC4tOpMU8nuVvFUEw6V/lwnG44jyOq+vgyDny2fxeUDMt9I4aQ==",
|
||||
"requires": {
|
||||
"@discordjs/collection": "^1.4.0",
|
||||
"@discordjs/collection": "^1.5.0",
|
||||
"@discordjs/util": "^0.2.0",
|
||||
"@sapphire/async-queue": "^1.5.0",
|
||||
"@sapphire/snowflake": "^3.4.0",
|
||||
"discord-api-types": "^0.37.35",
|
||||
"discord-api-types": "^0.37.37",
|
||||
"file-type": "^18.2.1",
|
||||
"tslib": "^2.5.0",
|
||||
"undici": "^5.20.0"
|
||||
"undici": "^5.21.0"
|
||||
}
|
||||
},
|
||||
"@discordjs/util": {
|
||||
|
@ -7420,23 +7441,23 @@
|
|||
"integrity": "sha512-LDMBKzl/zbvHO/yCzno5hevuA6lFIXJwdKSJZQrB+1ToDpFfN9thK+xxgZNR4aVkI7GHRDja0p4Sl2oYVPnHYg=="
|
||||
},
|
||||
"discord.js": {
|
||||
"version": "14.8.0",
|
||||
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.8.0.tgz",
|
||||
"integrity": "sha512-UOxYtc/YnV7jAJ2gISluJyYeBw4e+j8gWn+IoqG8unaHAVuvZ13DdYN0M1f9fbUgUvSarV798inIrYFtDNDjwQ==",
|
||||
"version": "14.9.0",
|
||||
"resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.9.0.tgz",
|
||||
"integrity": "sha512-ygGms5xP4hG+QrrY9k7d/OYCzMltSMtdl/2Snzq/nLCiZo+Sna91Ulv9l0+B5Jd/Czcq37B7wJAnmja7GOa+bg==",
|
||||
"requires": {
|
||||
"@discordjs/builders": "^1.5.0",
|
||||
"@discordjs/collection": "^1.4.0",
|
||||
"@discordjs/formatters": "^0.2.0",
|
||||
"@discordjs/rest": "^1.6.0",
|
||||
"@discordjs/builders": "^1.6.0",
|
||||
"@discordjs/collection": "^1.5.0",
|
||||
"@discordjs/formatters": "^0.3.0",
|
||||
"@discordjs/rest": "^1.7.0",
|
||||
"@discordjs/util": "^0.2.0",
|
||||
"@sapphire/snowflake": "^3.4.0",
|
||||
"@types/ws": "^8.5.4",
|
||||
"discord-api-types": "^0.37.35",
|
||||
"discord-api-types": "^0.37.37",
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"lodash.snakecase": "^4.1.1",
|
||||
"tslib": "^2.5.0",
|
||||
"undici": "^5.20.0",
|
||||
"ws": "^8.12.1"
|
||||
"undici": "^5.21.0",
|
||||
"ws": "^8.13.0"
|
||||
}
|
||||
},
|
||||
"dot-prop": {
|
||||
|
@ -8343,11 +8364,11 @@
|
|||
}
|
||||
},
|
||||
"knub": {
|
||||
"version": "32.0.0-next.6",
|
||||
"resolved": "https://registry.npmjs.org/knub/-/knub-32.0.0-next.6.tgz",
|
||||
"integrity": "sha512-rrpNM1RyVNhTFradUNTc+0MC3JeYHvlVs9+v7MsdozR6gryIIDr8Tf2+pt749MpFW+ZGNXBMR/iIPVIp+6oPSA==",
|
||||
"version": "32.0.0-next.8",
|
||||
"resolved": "https://registry.npmjs.org/knub/-/knub-32.0.0-next.8.tgz",
|
||||
"integrity": "sha512-/T152tJUQFD+aAMg72BbUjfhy/tofnF5TBYTc7vR2KLssh36cOlpZs7BSPg+EDreg9S8xhAMyCDwkm8AQyRHOg==",
|
||||
"requires": {
|
||||
"discord.js": "^14.8.0",
|
||||
"discord.js": "^14.9.0",
|
||||
"knub-command-manager": "^9.1.0",
|
||||
"ts-essentials": "^9",
|
||||
"zod": "^3.19.1"
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
"cors": "^2.8.5",
|
||||
"cross-env": "^5.2.0",
|
||||
"deep-diff": "^1.0.2",
|
||||
"discord.js": "^14.8.0",
|
||||
"discord.js": "^14.9.0",
|
||||
"dotenv": "^4.0.0",
|
||||
"emoji-regex": "^8.0.0",
|
||||
"erlpack": "github:discord/erlpack",
|
||||
|
@ -38,7 +38,7 @@
|
|||
"humanize-duration": "^3.15.0",
|
||||
"io-ts": "^2.0.0",
|
||||
"js-yaml": "^3.13.1",
|
||||
"knub": "^32.0.0-next.6",
|
||||
"knub": "^32.0.0-next.8",
|
||||
"knub-command-manager": "^9.1.0",
|
||||
"last-commit-log": "^2.1.0",
|
||||
"lodash.chunk": "^4.2.0",
|
||||
|
|
|
@ -25,7 +25,7 @@ import { isStaff } from "./staff";
|
|||
import { TZeppelinKnub } from "./types";
|
||||
import { errorMessage, successMessage, tNullable } from "./utils";
|
||||
import { Tail } from "./utils/typeUtils";
|
||||
import { StrictValidationError, validate } from "./validatorUtils";
|
||||
import { parseIoTsSchema, StrictValidationError } from "./validatorUtils";
|
||||
|
||||
const { getMemberLevel } = helpers;
|
||||
|
||||
|
@ -110,11 +110,14 @@ export function strictValidationErrorToConfigValidationError(err: StrictValidati
|
|||
|
||||
export function makeIoTsConfigParser<Schema extends t.Type<any>>(schema: Schema): (input: unknown) => t.TypeOf<Schema> {
|
||||
return (input: unknown) => {
|
||||
const error = validate(schema, input);
|
||||
if (error) {
|
||||
throw strictValidationErrorToConfigValidationError(error);
|
||||
try {
|
||||
return parseIoTsSchema(schema, input);
|
||||
} catch (err) {
|
||||
if (err instanceof StrictValidationError) {
|
||||
throw strictValidationErrorToConfigValidationError(err);
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
return input as t.TypeOf<Schema>;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import * as t from "io-ts";
|
||||
import { configUtils, CooldownManager } from "knub";
|
||||
import { GuildAntiraidLevels } from "../../data/GuildAntiraidLevels";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
|
@ -9,7 +8,7 @@ import { discardRegExpRunner, getRegExpRunner } from "../../regExpRunners";
|
|||
import { MINUTES, SECONDS } from "../../utils";
|
||||
import { registerEventListenersFromMap } from "../../utils/registerEventListenersFromMap";
|
||||
import { unregisterEventListenersFromMap } from "../../utils/unregisterEventListenersFromMap";
|
||||
import { StrictValidationError, validate } from "../../validatorUtils";
|
||||
import { parseIoTsSchema, StrictValidationError } from "../../validatorUtils";
|
||||
import { CountersPlugin } from "../Counters/CountersPlugin";
|
||||
import { InternalPosterPlugin } from "../InternalPoster/InternalPosterPlugin";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin";
|
||||
|
@ -181,12 +180,7 @@ const configParser = (input: unknown) => {
|
|||
}
|
||||
}
|
||||
|
||||
const error = validate(ConfigSchema, input);
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return input as t.TypeOf<typeof ConfigSchema>;
|
||||
return parseIoTsSchema(ConfigSchema, input);
|
||||
};
|
||||
|
||||
export const AutomodPlugin = zeppelinGuildPlugin<AutomodPluginType>()({
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import { EventEmitter } from "events";
|
||||
import * as t from "io-ts";
|
||||
import { PluginOptions } from "knub";
|
||||
import {
|
||||
buildCounterConditionString,
|
||||
|
@ -10,7 +9,7 @@ import {
|
|||
import { GuildCounters } from "../../data/GuildCounters";
|
||||
import { mapToPublicFn } from "../../pluginUtils";
|
||||
import { convertDelayStringToMS, MINUTES } from "../../utils";
|
||||
import { StrictValidationError, validate } from "../../validatorUtils";
|
||||
import { parseIoTsSchema, StrictValidationError } from "../../validatorUtils";
|
||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { AddCounterCmd } from "./commands/AddCounterCmd";
|
||||
import { CountersListCmd } from "./commands/CountersListCmd";
|
||||
|
@ -115,12 +114,7 @@ export const CountersPlugin = zeppelinGuildPlugin<CountersPluginType>()({
|
|||
throw new StrictValidationError([`You can only have at most ${MAX_COUNTERS} counters`]);
|
||||
}
|
||||
|
||||
const error = validate(ConfigSchema, input);
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return input as t.TypeOf<typeof ConfigSchema>;
|
||||
return parseIoTsSchema(ConfigSchema, input);
|
||||
},
|
||||
|
||||
public: {
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import * as t from "io-ts";
|
||||
import { GuildRoleButtons } from "../../data/GuildRoleButtons";
|
||||
import { StrictValidationError, validate } from "../../validatorUtils";
|
||||
import { parseIoTsSchema, StrictValidationError } from "../../validatorUtils";
|
||||
import { LogsPlugin } from "../Logs/LogsPlugin";
|
||||
import { RoleManagerPlugin } from "../RoleManager/RoleManagerPlugin";
|
||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
|
@ -65,12 +64,7 @@ export const RoleButtonsPlugin = zeppelinGuildPlugin<RoleButtonsPluginType>()({
|
|||
}
|
||||
}
|
||||
|
||||
const error = validate(ConfigSchema, input);
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return input as t.TypeOf<typeof ConfigSchema>;
|
||||
return parseIoTsSchema(ConfigSchema, input);
|
||||
},
|
||||
|
||||
dependencies: () => [LogsPlugin, RoleManagerPlugin],
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import * as t from "io-ts";
|
||||
import { CooldownManager, PluginOptions } from "knub";
|
||||
import { trimPluginDescription } from "../../utils";
|
||||
import { validate } from "../../validatorUtils";
|
||||
import { parseIoTsSchema } from "../../validatorUtils";
|
||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { RoleAddCmd } from "./commands/RoleAddCmd";
|
||||
import { RoleHelpCmd } from "./commands/RoleHelpCmd";
|
||||
|
@ -84,12 +83,7 @@ export const SelfGrantableRolesPlugin = zeppelinGuildPlugin<SelfGrantableRolesPl
|
|||
}
|
||||
}
|
||||
|
||||
const error = validate(ConfigSchema, input);
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return input as t.TypeOf<typeof ConfigSchema>;
|
||||
return parseIoTsSchema(ConfigSchema, input);
|
||||
},
|
||||
defaultOptions,
|
||||
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import * as t from "io-ts";
|
||||
import { PluginOptions } from "knub";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
import { GuildStarboardMessages } from "../../data/GuildStarboardMessages";
|
||||
import { GuildStarboardReactions } from "../../data/GuildStarboardReactions";
|
||||
import { trimPluginDescription } from "../../utils";
|
||||
import { validate } from "../../validatorUtils";
|
||||
import { parseIoTsSchema } from "../../validatorUtils";
|
||||
import { zeppelinGuildPlugin } from "../ZeppelinPluginBlueprint";
|
||||
import { MigratePinsCmd } from "./commands/MigratePinsCmd";
|
||||
import { StarboardReactionAddEvt } from "./events/StarboardReactionAddEvt";
|
||||
|
@ -132,12 +131,7 @@ export const StarboardPlugin = zeppelinGuildPlugin<StarboardPluginType>()({
|
|||
}
|
||||
}
|
||||
|
||||
const error = validate(ConfigSchema, input);
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return input as t.TypeOf<typeof ConfigSchema>;
|
||||
return parseIoTsSchema(ConfigSchema, input);
|
||||
},
|
||||
defaultOptions,
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { Snowflake } from "discord.js";
|
||||
import humanizeDuration from "humanize-duration";
|
||||
import * as t from "io-ts";
|
||||
import { PluginOptions } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
import { StrictValidationError, validate } from "src/validatorUtils";
|
||||
import { parseIoTsSchema, StrictValidationError } from "src/validatorUtils";
|
||||
import { GuildArchives } from "../../data/GuildArchives";
|
||||
import { GuildLogs } from "../../data/GuildLogs";
|
||||
import { GuildSavedMessages } from "../../data/GuildSavedMessages";
|
||||
|
@ -118,12 +117,7 @@ export const TagsPlugin = zeppelinGuildPlugin<TagsPluginType>()({
|
|||
}
|
||||
}
|
||||
|
||||
const error = validate(ConfigSchema, input);
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
return input as t.TypeOf<typeof ConfigSchema>;
|
||||
return parseIoTsSchema(ConfigSchema, input);
|
||||
},
|
||||
|
||||
beforeLoad(pluginData) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import deepDiff from "deep-diff";
|
||||
import { either, fold } from "fp-ts/lib/Either";
|
||||
import { either, fold, isLeft } from "fp-ts/lib/Either";
|
||||
import { pipe } from "fp-ts/lib/pipeable";
|
||||
import * as t from "io-ts";
|
||||
import { noop } from "./utils";
|
||||
|
@ -106,6 +106,14 @@ export function validate(schema: t.Type<any>, value: any): StrictValidationError
|
|||
);
|
||||
}
|
||||
|
||||
export function parseIoTsSchema<T extends t.Type<any>>(schema: T, value: unknown): t.TypeOf<T> {
|
||||
const decodeResult = schema.decode(value);
|
||||
if (isLeft(decodeResult)) {
|
||||
throw report(decodeResult);
|
||||
}
|
||||
return decodeResult.right;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes and validates the given value against the given schema while also disallowing extra properties
|
||||
* See: https://github.com/gcanti/io-ts/issues/322
|
||||
|
|
Loading…
Add table
Reference in a new issue