From 5e7c155f6e6be996a4a4c9aba99f18500032726a Mon Sep 17 00:00:00 2001 From: megumin Date: Tue, 25 Oct 2022 18:49:50 +0100 Subject: feat(settings): add beforeSave check (#161) --- src/utils/types.ts | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/utils') diff --git a/src/utils/types.ts b/src/utils/types.ts index 1916f9b..41dd0c1 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -16,6 +16,8 @@ * along with this program. If not, see . */ +import { Promisable } from "type-fest"; + import { Command } from "../api/Commands"; // exists to export default definePlugin({...}) @@ -75,6 +77,11 @@ interface PluginDef { * Optionally provide settings that the user can configure in the Plugins tab of settings. */ options?: Record; + /** + * Check that this returns true before allowing a save to complete. + * If a string is returned, show the error to the user. + */ + beforeSave?(options: Record): Promisable; /** * Allows you to specify a custom Component that will be rendered in your * plugin's settings page -- cgit