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

91c40280ed59ec43503a2645f6fd1c43f301099d

Leandro Jofré <leandrotomasjofre@gmail.com>

Signed
1 files changed, +23 -3Showing whitespace changes
public/scripts/extensions/expressions/index.js+23 -3
@@ -792,6 +792,8 @@ async function setSpriteSlashCommand({ type }, searchTerm) {
792function setFallBackExpressionSlashCommand(args, expressionName) {792function setFallBackExpressionSlashCommand(args, expressionName) {
793 expressionName = expressionName.trim().toLowerCase();793 expressionName = expressionName.trim().toLowerCase();
794794
795 if (!expressionName) return extension_settings?.expressions?.fallback_expression || '';
796
795 const select = /** @type {HTMLSelectElement} */(document.getElementById('expression_fallback'));797 const select = /** @type {HTMLSelectElement} */(document.getElementById('expression_fallback'));
796 const fallbackExpressions = Array798 const fallbackExpressions = Array
797 .from(select?.options || [])799 .from(select?.options || [])
@@ -2341,13 +2343,13 @@ export async function init() {
2341 returns: 'The currently set expression label after setting it.',2343 returns: 'The currently set expression label after setting it.',
2342 }));2344 }));
2343 SlashCommandParser.addCommandObject(SlashCommand.fromProps({2345 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
2344 name: 'expression-set-fallback',2346 name: 'expression-fallback',
2345 callback: setFallBackExpressionSlashCommand,2347 callback: setFallBackExpressionSlashCommand,
2346 unnamedArgumentList: [2348 unnamedArgumentList: [
2347 SlashCommandArgument.fromProps({2349 SlashCommandArgument.fromProps({
2348 description: 'expression label to set',2350 description: 'expression label to set',
2349 typeList: [ARGUMENT_TYPE.STRING],2351 typeList: [ARGUMENT_TYPE.STRING],
2350 isRequired: true,2352 isRequired: false,
2351 enumProvider: () => [2353 enumProvider: () => [
2352 new SlashCommandEnumValue('#none', 'Sets the fallback expression to no image'),2354 new SlashCommandEnumValue('#none', 'Sets the fallback expression to no image'),
2353 new SlashCommandEnumValue('#emoji', 'Sets the fallback expression to emojis'),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 returns: 'The currently set expression label after setting it.',2379 returns: 'The currently set expression label after setting it.',
2360 }));2380 }));
2361 SlashCommandParser.addCommandObject(SlashCommand.fromProps({2381 SlashCommandParser.addCommandObject(SlashCommand.fromProps({