Fix lint issues in enum providers
This commit is contained in:
parent
c4cc33cad9
commit
fbcd546db2
|
@ -6,7 +6,9 @@ import { searchCharByName, getTagsList, tags } from '../tags.js';
|
||||||
import { world_names } from '../world-info.js';
|
import { world_names } from '../world-info.js';
|
||||||
import { SlashCommandClosure } from './SlashCommandClosure.js';
|
import { SlashCommandClosure } from './SlashCommandClosure.js';
|
||||||
import { SlashCommandEnumValue, enumTypes } from './SlashCommandEnumValue.js';
|
import { SlashCommandEnumValue, enumTypes } from './SlashCommandEnumValue.js';
|
||||||
import { SlashCommandScope } from "./SlashCommandScope.js";
|
|
||||||
|
/** @typedef {import('./SlashCommandExecutor.js').SlashCommandExecutor} SlashCommandExecutor */
|
||||||
|
/** @typedef {import('./SlashCommandScope.js').SlashCommandScope} SlashCommandScope */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of regularly used enum icons
|
* A collection of regularly used enum icons
|
||||||
|
@ -140,7 +142,7 @@ export const commonEnumProviders = {
|
||||||
* @param {...('global'|'local'|'scope'|'all')} type - The type of variables to include in the array. Can be 'all', 'global', or 'local'.
|
* @param {...('global'|'local'|'scope'|'all')} type - The type of variables to include in the array. Can be 'all', 'global', or 'local'.
|
||||||
* @returns {(executor:SlashCommandExecutor, scope:SlashCommandScope) => SlashCommandEnumValue[]}
|
* @returns {(executor:SlashCommandExecutor, scope:SlashCommandScope) => SlashCommandEnumValue[]}
|
||||||
*/
|
*/
|
||||||
variables: (...type) => (executor, scope) => {
|
variables: (...type) => (_, scope) => {
|
||||||
const types = type.flat();
|
const types = type.flat();
|
||||||
const isAll = types.includes('all');
|
const isAll = types.includes('all');
|
||||||
return [
|
return [
|
||||||
|
@ -184,7 +186,7 @@ export const commonEnumProviders = {
|
||||||
* @param {('all' | 'existing' | 'not-existing')?} [mode='all'] - Which types of tags to show
|
* @param {('all' | 'existing' | 'not-existing')?} [mode='all'] - Which types of tags to show
|
||||||
* @returns {() => SlashCommandEnumValue[]}
|
* @returns {() => SlashCommandEnumValue[]}
|
||||||
*/
|
*/
|
||||||
tagsForChar: (mode = 'all') => (/** @type {import('./SlashCommandExecutor.js').SlashCommandExecutor} */ executor) => {
|
tagsForChar: (mode = 'all') => (/** @type {SlashCommandExecutor} */ executor) => {
|
||||||
// Try to see if we can find the char during execution to filter down the tags list some more. Otherwise take all tags.
|
// Try to see if we can find the char during execution to filter down the tags list some more. Otherwise take all tags.
|
||||||
const charName = executor.namedArgumentList.find(it => it.name == 'name')?.value;
|
const charName = executor.namedArgumentList.find(it => it.name == 'name')?.value;
|
||||||
if (charName instanceof SlashCommandClosure) throw new Error('Argument \'name\' does not support closures');
|
if (charName instanceof SlashCommandClosure) throw new Error('Argument \'name\' does not support closures');
|
||||||
|
@ -202,13 +204,13 @@ export const commonEnumProviders = {
|
||||||
* @param {object} [options={}] - Optional arguments
|
* @param {object} [options={}] - Optional arguments
|
||||||
* @param {boolean} [options.allowIdAfter=false] - Whether to add an enum option for the new message id after the last message
|
* @param {boolean} [options.allowIdAfter=false] - Whether to add an enum option for the new message id after the last message
|
||||||
* @param {boolean} [options.allowVars=false] - Whether to add enum option for variable names
|
* @param {boolean} [options.allowVars=false] - Whether to add enum option for variable names
|
||||||
* @returns {() => SlashCommandEnumValue[]}
|
* @returns {(executor:SlashCommandExecutor, scope:SlashCommandScope) => SlashCommandEnumValue[]}
|
||||||
*/
|
*/
|
||||||
messages: ({ allowIdAfter = false, allowVars = false } = {}) => () => {
|
messages: ({ allowIdAfter = false, allowVars = false } = {}) => (_, scope) => {
|
||||||
return [
|
return [
|
||||||
...chat.map((message, index) => new SlashCommandEnumValue(String(index), `${message.name}: ${message.mes}`, enumTypes.number, message.is_user ? enumIcons.user : message.is_system ? enumIcons.system : enumIcons.assistant)),
|
...chat.map((message, index) => new SlashCommandEnumValue(String(index), `${message.name}: ${message.mes}`, enumTypes.number, message.is_user ? enumIcons.user : message.is_system ? enumIcons.system : enumIcons.assistant)),
|
||||||
...allowIdAfter ? [new SlashCommandEnumValue(String(chat.length), '>> After Last Message >>', enumTypes.enum, '➕')] : [],
|
...allowIdAfter ? [new SlashCommandEnumValue(String(chat.length), '>> After Last Message >>', enumTypes.enum, '➕')] : [],
|
||||||
...allowVars ? commonEnumProviders.variables('all')() : [],
|
...allowVars ? commonEnumProviders.variables('all')(_, scope) : [],
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue