mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-25 18:25:03 +00:00
fix: use Knub's config validation logic in API
This commit is contained in:
parent
9b6177ca23
commit
04ae4eeb14
1 changed files with 6 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
|||
import { configUtils, ConfigValidationError, PluginOptions } from "knub";
|
||||
import { ConfigValidationError, PluginConfigManager } from "knub";
|
||||
import moment from "moment-timezone";
|
||||
import { guildPlugins } from "./plugins/availablePlugins";
|
||||
import { ZeppelinPlugin } from "./plugins/ZeppelinPlugin";
|
||||
|
@ -34,9 +34,12 @@ export async function validateGuildConfig(config: any): Promise<string | null> {
|
|||
}
|
||||
|
||||
const plugin = pluginNameToPlugin.get(pluginName)!;
|
||||
const configManager = new PluginConfigManager(plugin.defaultOptions || { config: {} }, pluginOptions, {
|
||||
levels: {},
|
||||
parser: plugin.configParser,
|
||||
});
|
||||
try {
|
||||
const mergedOptions = configUtils.mergeConfig(plugin.defaultOptions || {}, pluginOptions);
|
||||
await plugin.configParser?.(mergedOptions as unknown as PluginOptions<any>);
|
||||
await configManager.init();
|
||||
} catch (err) {
|
||||
if (err instanceof ConfigValidationError || err instanceof StrictValidationError) {
|
||||
return `${pluginName}: ${err.message}`;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue