| 4072 | 4072 | ], |
| 4073 | 4073 | helpString: 'activates a movingUI preset by name', |
| 4074 | 4074 | })); |
| 4075 | + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 4076 | + name: 'stop-strings', |
| 4077 | + aliases: ['stopping-strings', 'custom-stopping-strings', 'custom-stop-strings'], |
| 4078 | + helpString: ` |
| 4079 | + <div> |
| 4080 | + Sets a list of custom stopping strings. Gets the list if no value is provided. |
| 4081 | + </div> |
| 4082 | + <div> |
| 4083 | + <strong>Examples:</strong> |
| 4084 | + </div> |
| 4085 | + <ul> |
| 4086 | + <li>Value must be a JSON-serialized array: <pre><code class="language-stscript">/stop-strings ["goodbye", "farewell"]</code></pre></li> |
| 4087 | + <li>Pipe characters must be escaped with a backslash: <pre><code class="language-stscript">/stop-strings ["left\\|right"]</code></pre></li> |
| 4088 | + </ul> |
| 4089 | + `, |
| 4090 | + returns: ARGUMENT_TYPE.LIST, |
| 4091 | + unnamedArgumentList: [ |
| 4092 | + SlashCommandArgument.fromProps({ |
| 4093 | + description: 'list of strings', |
| 4094 | + typeList: [ARGUMENT_TYPE.LIST], |
| 4095 | + acceptsMultiple: false, |
| 4096 | + isRequired: false, |
| 4097 | + }), |
| 4098 | + ], |
| 4099 | + callback: (_, value) => { |
| 4100 | + if (String(value ?? '').trim()) { |
| 4101 | + const parsedValue = ((x) => { try { return JSON.parse(x.toString()); } catch { return null; } })(value); |
| 4102 | + if (!parsedValue || !Array.isArray(parsedValue)) { |
| 4103 | + throw new Error('Invalid list format. The value must be a JSON-serialized array of strings.'); |
| 4104 | + } |
| 4105 | + parsedValue.forEach((item, index) => { |
| 4106 | + parsedValue[index] = String(item); |
| 4107 | + }); |
| 4108 | + power_user.custom_stopping_strings = JSON.stringify(parsedValue); |
| 4109 | + $('#custom_stopping_strings').val(power_user.custom_stopping_strings); |
| 4110 | + saveSettingsDebounced(); |
| 4111 | + } |
| 4112 | + |
| 4113 | + return power_user.custom_stopping_strings; |
| 4114 | + }, |
| 4115 | + })); |
| 4075 | 4116 | }); |