Update/Turn expression-set-fallback into expression-fallback (#5564) * Update - Turn expression-set-fallback into expression-fallback Make the extension a getter and setter instead of a setter only. * Update - Rewrite the help string and add usage examples * Fix - Remove the alias
Signed| @@ -792,6 +792,8 @@ async function setSpriteSlashCommand({ type }, searchTerm) { | ||
| 792 | 792 | function setFallBackExpressionSlashCommand(args, expressionName) { |
| 793 | 793 | expressionName = expressionName.trim().toLowerCase(); |
| 794 | 794 | |
| 795 | + if (!expressionName) return extension_settings?.expressions?.fallback_expression || ''; | |
| 796 | + | |
| 795 | 797 | const select = /** @type {HTMLSelectElement} */(document.getElementById('expression_fallback')); |
| 796 | 798 | const fallbackExpressions = Array |
| 797 | 799 | .from(select?.options || []) |
| @@ -2341,13 +2343,13 @@ export async function init() { | ||
| 2341 | 2343 | returns: 'The currently set expression label after setting it.', |
| 2342 | 2344 | })); |
| 2343 | 2345 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |
| 2344 | 2346 | name: 'expression-set-fallback', |
| 2345 | 2347 | callback: setFallBackExpressionSlashCommand, |
| 2346 | 2348 | unnamedArgumentList: [ |
| 2347 | 2349 | SlashCommandArgument.fromProps({ |
| 2348 | 2350 | description: 'expression label to set', |
| 2349 | 2351 | typeList: [ARGUMENT_TYPE.STRING], |
| 2350 | 2352 | isRequired: truefalse, |
| 2351 | 2353 | enumProvider: () => [ |
| 2352 | 2354 | new SlashCommandEnumValue('#none', 'Sets the fallback expression to no image'), |
| 2353 | 2355 | new SlashCommandEnumValue('#emoji', 'Sets the fallback expression to emojis'), |
| @@ -2355,7 +2357,25 @@ export async function init() { | ||
| 2355 | 2357 | ], |
| 2356 | 2358 | }), |
| 2357 | 2359 | ], |
| 2358 | - helpString: 'Force sets the expression fallback for all characters.', | |
| 2360 | + helpString: ` | |
| 2361 | + <div> | |
| 2362 | + Gets the currently selected expression fallback for all characters.<br /> | |
| 2363 | + If a valid expression label is sent, it will be set as the new fallback. | |
| 2364 | + </div> | |
| 2365 | + <div> | |
| 2366 | + <strong>Example:</strong> | |
| 2367 | + <ul> | |
| 2368 | + <li> | |
| 2369 | + <pre><code>/expression-fallback | /echo</code></pre> | |
| 2370 | + <small>Returns the currently selected fallback.</small> | |
| 2371 | + </li> | |
| 2372 | + <li> | |
| 2373 | + <pre><code>/expression-fallback admiration</code></pre> | |
| 2374 | + <small>Sets a new expression as fallback.</small> | |
| 2375 | + </li> | |
| 2376 | + </ul> | |
| 2377 | + </div> | |
| 2378 | + `, | |
| 2359 | 2379 | returns: 'The currently set expression label after setting it.', |
| 2360 | 2380 | })); |
| 2361 | 2381 | SlashCommandParser.addCommandObject(SlashCommand.fromProps({ |