Merged redundant args for /setpromptentry
This commit is contained in:
parent
e5d9f2937e
commit
7f284a3752
|
@ -1211,20 +1211,14 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||||
callback: setPromptEntryCallback,
|
callback: setPromptEntryCallback,
|
||||||
namedArgumentList: [
|
namedArgumentList: [
|
||||||
new SlashCommandNamedArgument(
|
new SlashCommandNamedArgument(
|
||||||
'identifier', 'Prompt entry identifier to set (UUID)', [ARGUMENT_TYPE.STRING], false,
|
'identifier', 'Prompt entry identifier(s) to target', [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.LIST], false, true,
|
||||||
),
|
),
|
||||||
new SlashCommandNamedArgument(
|
new SlashCommandNamedArgument(
|
||||||
'identifiers', 'List of prompt entry identifiers to set (UUID)', [ARGUMENT_TYPE.LIST], false,
|
'name', 'Prompt entry name(s) to target', [ARGUMENT_TYPE.STRING, ARGUMENT_TYPE.LIST], false, true,
|
||||||
),
|
|
||||||
new SlashCommandNamedArgument(
|
|
||||||
'name', 'Prompt entry name to set', [ARGUMENT_TYPE.STRING], false,
|
|
||||||
),
|
|
||||||
new SlashCommandNamedArgument(
|
|
||||||
'names', 'Prompt entry names to set', [ARGUMENT_TYPE.LIST], false,
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
unnamedArgumentList: [
|
unnamedArgumentList: [
|
||||||
SlashCommandArgument.fromProps({ description: 'Set entry/entries on, off or toggle current state',
|
SlashCommandArgument.fromProps({ description: 'Set entry/entries on or off',
|
||||||
typeList: [ARGUMENT_TYPE.STRING],
|
typeList: [ARGUMENT_TYPE.STRING],
|
||||||
isRequired: true,
|
isRequired: true,
|
||||||
acceptsMultiple: false,
|
acceptsMultiple: false,
|
||||||
|
@ -1232,7 +1226,7 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
|
||||||
enumList: ['on', 'off', 'toggle'],
|
enumList: ['on', 'off', 'toggle'],
|
||||||
}),
|
}),
|
||||||
],
|
],
|
||||||
helpString: 'Sets or toggles individual chat completion prompt entries.',
|
helpString: 'Sets the model for the current API. Gets the current model name if no argument is provided.',
|
||||||
}));
|
}));
|
||||||
|
|
||||||
registerVariableCommands();
|
registerVariableCommands();
|
||||||
|
@ -2860,9 +2854,7 @@ function modelCallback(_, model) {
|
||||||
* Sets state of prompt entries (toggles) either via identifier/uuid or name.
|
* Sets state of prompt entries (toggles) either via identifier/uuid or name.
|
||||||
* @param {object} args Object containing arguments
|
* @param {object} args Object containing arguments
|
||||||
* @param {string} args.identifier Select prompt entry using an identifier (uuid)
|
* @param {string} args.identifier Select prompt entry using an identifier (uuid)
|
||||||
* @param {string} args.identifiers List of identifiers to set
|
|
||||||
* @param {string} args.name Select prompt entry using name
|
* @param {string} args.name Select prompt entry using name
|
||||||
* @param {string} args.names List of names to set
|
|
||||||
* @param {string} targetState The targeted state of the entry/entries
|
* @param {string} targetState The targeted state of the entry/entries
|
||||||
* @returns {String} empty string
|
* @returns {String} empty string
|
||||||
*/
|
*/
|
||||||
|
@ -2872,15 +2864,14 @@ function setPromptEntryCallback(args, targetState) {
|
||||||
const prompts = promptManager.serviceSettings.prompts;
|
const prompts = promptManager.serviceSettings.prompts;
|
||||||
|
|
||||||
let identifiersList = [];
|
let identifiersList = [];
|
||||||
// Check identifier(s) args
|
// Check identifiers args
|
||||||
if (args.identifier) identifiersList.push(args.identifier);
|
try {
|
||||||
if (args.identifiers) {
|
const parsedIdentifiers = JSON.parse(args.identifier);
|
||||||
try {
|
identifiersList = identifiersList.concat(Array.isArray(parsedIdentifiers) ? parsedIdentifiers : [args.identifier]);
|
||||||
identifiersList = identifiersList.concat(JSON.parse(args.identifiers));
|
} catch {
|
||||||
} catch {
|
identifiersList.push(args.identifier);
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if identifiers exists in prompt, else remove from list
|
// Check if identifiers exists in prompt, else remove from list
|
||||||
if (identifiersList.length !== 0) {
|
if (identifiersList.length !== 0) {
|
||||||
identifiersList = identifiersList.filter(identifier => {
|
identifiersList = identifiersList.filter(identifier => {
|
||||||
|
@ -2890,13 +2881,11 @@ function setPromptEntryCallback(args, targetState) {
|
||||||
|
|
||||||
let nameList = [];
|
let nameList = [];
|
||||||
// Get list of names
|
// Get list of names
|
||||||
if (args.name) nameList.push(args.name);
|
try {
|
||||||
if (args.names) {
|
const parsedNames = JSON.parse(args.name);
|
||||||
try {
|
nameList = nameList.concat(Array.isArray(parsedNames) ? parsedNames : [args.name]);
|
||||||
nameList = nameList.concat(JSON.parse(args.names));
|
} catch {
|
||||||
} catch {
|
nameList.push(args.name);
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nameList.length !== 0) {
|
if (nameList.length !== 0) {
|
||||||
|
|
Loading…
Reference in New Issue