diff --git a/src/api/Settings.ts b/src/api/Settings.ts index ed38ad75e..0e2fcf89c 100644 --- a/src/api/Settings.ts +++ b/src/api/Settings.ts @@ -220,9 +220,9 @@ export function migratePluginSettings(name: string, ...oldNames: string[]) { } } -export function migrateSettingsToArrays(pluginName: string, settings: Array, stringSeparator: string = ",") { +export function migrateSettingsToArrays(pluginName: string, settings: string[], stringSeparator: string = ",") { for (const setting of settings) { - if (typeof SettingsStore.plain.plugins[pluginName][setting] !== "string") continue; + if (SettingsStore.plain.plugins[pluginName] === undefined || typeof SettingsStore.plain.plugins[pluginName][setting] !== "string") continue; logger.info(`Migrating setting ${setting} from ${pluginName} to list`); if (SettingsStore.plain.plugins[pluginName][setting] === "") SettingsStore.plain.plugins[pluginName][setting] = []; else SettingsStore.plain.plugins[pluginName][setting] = SettingsStore.plain.plugins[pluginName][setting].split(stringSeparator); diff --git a/src/components/PluginSettings/components/SettingArrayComponent.tsx b/src/components/PluginSettings/components/SettingArrayComponent.tsx index 9718e8723..dbf478470 100644 --- a/src/components/PluginSettings/components/SettingArrayComponent.tsx +++ b/src/components/PluginSettings/components/SettingArrayComponent.tsx @@ -91,7 +91,12 @@ export function SettingArrayComponent({ if (!inputElement || inputElement.value === "") { return; } - // TODO add searching for users, channels, and guilds lol + // TODO add picker for users? + if (option.type !== OptionType.ARRAY && !(inputElement.value.length >= 18 && inputElement.value.length <= 19 && !isNaN(Number(inputElement.value)))) { + setError("Value is not a valid snowflake ID"); + inputElement.value = ""; + return; + } setItems([...items, inputElement.value]); pluginSettings[id] = items; inputElement.value = ""; @@ -149,7 +154,7 @@ export function SettingArrayComponent({ {/* Add a single input field */} {/* Add a submit button */}