Add command and profile for custom stop strings

This commit is contained in:
Cohee
2025-01-27 22:30:35 +02:00
parent 3b8fd6f62f
commit fad4e4e75e
2 changed files with 34 additions and 0 deletions

View File

@ -4072,4 +4072,34 @@ $(document).ready(() => {
],
helpString: 'activates a movingUI preset by name',
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'stop-strings',
aliases: ['stopping-strings'],
helpString: 'Sets a list of custom stopping strings. Gets the list if no value is provided.',
returns: ARGUMENT_TYPE.LIST,
unnamedArgumentList: [
SlashCommandArgument.fromProps({
description: 'list of strings',
typeList: [ARGUMENT_TYPE.LIST],
acceptsMultiple: false,
isRequired: false,
}),
],
callback: (_, value) => {
if (String(value ?? '').trim()) {
const parsedValue = ((x) => { try { return JSON.parse(x.toString()); } catch { return null; } })(value);
if (!parsedValue || !Array.isArray(parsedValue)) {
throw new Error('Invalid list format. The value must be a JSON-serialized array of strings.');
}
parsedValue.forEach((item, index) => {
parsedValue[index] = String(item);
});
power_user.custom_stopping_strings = JSON.stringify(parsedValue);
$('#custom_stopping_strings').val(power_user.custom_stopping_strings);
saveSettingsDebounced();
}
return power_user.custom_stopping_strings;
},
}));
});