Refactor /popup args and docs, add 'cancelButton'

This commit is contained in:
Wolfsblvt
2024-09-06 22:38:02 +02:00
parent a9e4bef01b
commit a9c0dd38c7

View File

@ -1267,21 +1267,41 @@ export function initDefaultSlashCommands() {
callback: popupCallback, callback: popupCallback,
returns: 'popup text', returns: 'popup text',
namedArgumentList: [ namedArgumentList: [
new SlashCommandNamedArgument( SlashCommandNamedArgument.fromProps({
'large', 'show large popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(), name: 'large',
), description: 'show large popup',
new SlashCommandNamedArgument( typeList: [ARGUMENT_TYPE.BOOLEAN],
'wide', 'show wide popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(), enumList: commonEnumProviders.boolean('onOff')(),
), }),
new SlashCommandNamedArgument( SlashCommandNamedArgument.fromProps({
'wider', 'show wider popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(), name: 'wide',
), description: 'show wide popup',
new SlashCommandNamedArgument( typeList: [ARGUMENT_TYPE.BOOLEAN],
'transparent', 'show transparent popup', [ARGUMENT_TYPE.BOOLEAN], false, false, null, commonEnumProviders.boolean('onOff')(), enumList: commonEnumProviders.boolean('onOff')(),
), }),
new SlashCommandNamedArgument( SlashCommandNamedArgument.fromProps({
'okButton', 'text for the OK button', [ARGUMENT_TYPE.STRING], false, name: 'wider',
), description: 'show wider popup',
typeList: [ARGUMENT_TYPE.BOOLEAN],
enumList: commonEnumProviders.boolean('onOff')(),
}),
SlashCommandNamedArgument.fromProps({
name: 'transparent',
description: 'show transparent popup',
typeList: [ARGUMENT_TYPE.BOOLEAN],
enumList: commonEnumProviders.boolean('onOff')(),
}),
SlashCommandNamedArgument.fromProps({
name: 'okButton',
description: 'text for the OK button',
typeList: [ARGUMENT_TYPE.STRING],
defaultValue: 'OK',
}),
SlashCommandNamedArgument.fromProps({
name: 'cancelButton',
description: 'text for the Cancel button',
typeList: [ARGUMENT_TYPE.STRING],
}),
], ],
unnamedArgumentList: [ unnamedArgumentList: [
new SlashCommandArgument( new SlashCommandArgument(
@ -1297,7 +1317,7 @@ export function initDefaultSlashCommands() {
<strong>Example:</strong> <strong>Example:</strong>
<ul> <ul>
<li> <li>
<pre><code>/popup large=on wide=on okButton="Submit" Enter some text:</code></pre> <pre><code>/popup large=on wide=on okButton="Confirm" Please confirm this action.</code></pre>
</li> </li>
</ul> </ul>
</div> </div>
@ -1896,10 +1916,9 @@ async function popupCallback(args, value) {
wider: isTrueBoolean(args?.wider), wider: isTrueBoolean(args?.wider),
transparent: isTrueBoolean(args?.transparent), transparent: isTrueBoolean(args?.transparent),
okButton: args?.okButton !== undefined && typeof args?.okButton === 'string' ? args.okButton : 'Ok', okButton: args?.okButton !== undefined && typeof args?.okButton === 'string' ? args.okButton : 'Ok',
cancelButton: args?.cancelButton !== undefined && typeof args?.cancelButton === 'string' ? args.cancelButton : null,
}; };
await delay(1);
await callGenericPopup(safeValue, POPUP_TYPE.TEXT, '', popupOptions); await callGenericPopup(safeValue, POPUP_TYPE.TEXT, '', popupOptions);
await delay(1);
return String(value); return String(value);
} }