mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
Several million refactoring of existing slash commands with enums (really)
This commit is contained in:
@ -30,22 +30,27 @@ export const commonEnumProviders = {
|
||||
},
|
||||
|
||||
/**
|
||||
* All possible character and group names
|
||||
* All possible char entities, like characters and groups. Can be filtered down to just one type.
|
||||
*
|
||||
* @returns {SlashCommandEnumValue[]}
|
||||
* @param {('all' | 'character' | 'group')?} [mode='all'] - Which type to return
|
||||
* @returns {() => SlashCommandEnumValue[]}
|
||||
*/
|
||||
charName: () => [
|
||||
...characters.map(it => new SlashCommandEnumValue(it.name, null, 'qr', 'C')),
|
||||
...groups.map(it => new SlashCommandEnumValue(it.name, null, 'variable', 'G')),
|
||||
],
|
||||
charName: (mode) => () => {
|
||||
mode = mode ?? 'all';
|
||||
return [
|
||||
...['all', 'character'].includes(mode) ? characters.map(it => new SlashCommandEnumValue(it.name, null, 'qr', 'C')) : [],
|
||||
...['all', 'group'].includes(mode) ? groups.map(it => new SlashCommandEnumValue(it.name, null, 'variable', 'G')) : [],
|
||||
];
|
||||
},
|
||||
|
||||
/**
|
||||
* All possible tags for a given char/group entity
|
||||
*
|
||||
* @param {'all' | 'existing' | 'not-existing'} mode - Which types of tags to show
|
||||
* @param {('all' | 'existing' | 'not-existing')?} [mode='all'] - Which types of tags to show
|
||||
* @returns {() => SlashCommandEnumValue[]}
|
||||
*/
|
||||
tagsForChar: (mode) => (/** @type {SlashCommandExecutor} */ executor) => {
|
||||
mode = mode ?? 'all';
|
||||
// Try to see if we can find the char during execution to filter down the tags list some more. Otherwise take all tags.
|
||||
const key = searchCharByName(substituteParams(/**@type {string?}*/(executor.namedArgumentList.find(it => it.name == 'name')?.value)), { suppressLogging: true });
|
||||
const assigned = key ? getTagsList(key) : [];
|
||||
@ -61,6 +66,14 @@ export const commonEnumProviders = {
|
||||
worlds: () => $('#world_info').children().toArray().map(x => new SlashCommandEnumValue(x.textContent)),
|
||||
};
|
||||
|
||||
/**
|
||||
* Get the enum values for boolean type, with class and icon
|
||||
*
|
||||
* @return {Array<SlashCommandEnumValue>} An array of SlashCommandEnumValue objects representing the boolean values 'true' and 'false'.
|
||||
*/
|
||||
export function getEnumBooleanValues() {
|
||||
return [new SlashCommandEnumValue('true', null, 'boolean', getEnumIconByValueType('boolean')), new SlashCommandEnumValue('false', null, 'boolean', getEnumIconByValueType('boolean'))];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the unicode icon for the given enum value type
|
||||
|
Reference in New Issue
Block a user