Fix lint issues in enum providers
| @@ -6,7 +6,9 @@ import { searchCharByName, getTagsList, tags } from '../tags.js'; | |||
| 6 | import { world_names } from '../world-info.js'; | 6 | import { world_names } from '../world-info.js'; |
| 7 | import { SlashCommandClosure } from './SlashCommandClosure.js'; | 7 | import { SlashCommandClosure } from './SlashCommandClosure.js'; |
| 8 | import { SlashCommandEnumValue, enumTypes } from './SlashCommandEnumValue.js'; | 8 | import { SlashCommandEnumValue, enumTypes } from './SlashCommandEnumValue.js'; |
| 9 | import { SlashCommandScope } from "./SlashCommandScope.js"; | 9 | |
| 10 | /** @typedef {import('./SlashCommandExecutor.js').SlashCommandExecutor} SlashCommandExecutor */ | ||
| 11 | /** @typedef {import('./SlashCommandScope.js').SlashCommandScope} SlashCommandScope */ | ||
| 10 | 12 | ||
| 11 | /** | 13 | /** |
| 12 | * A collection of regularly used enum icons | 14 | * A collection of regularly used enum icons |
| @@ -140,7 +142,7 @@ export const commonEnumProviders = { | |||
| 140 | * @param {...('global'|'local'|'scope'|'all')} type - The type of variables to include in the array. Can be 'all', 'global', or 'local'. | 142 | * @param {...('global'|'local'|'scope'|'all')} type - The type of variables to include in the array. Can be 'all', 'global', or 'local'. |
| 141 | * @returns {(executor:SlashCommandExecutor, scope:SlashCommandScope) => SlashCommandEnumValue[]} | 143 | * @returns {(executor:SlashCommandExecutor, scope:SlashCommandScope) => SlashCommandEnumValue[]} |
| 142 | */ | 144 | */ |
| 143 | variables: (...type) => (executor, scope) => { | 145 | variables: (...type) => (_, scope) => { |
| 144 | const types = type.flat(); | 146 | const types = type.flat(); |
| 145 | const isAll = types.includes('all'); | 147 | const isAll = types.includes('all'); |
| 146 | return [ | 148 | return [ |
| @@ -184,7 +186,7 @@ export const commonEnumProviders = { | |||
| 184 | * @param {('all' | 'existing' | 'not-existing')?} [mode='all'] - Which types of tags to show | 186 | * @param {('all' | 'existing' | 'not-existing')?} [mode='all'] - Which types of tags to show |
| 185 | * @returns {() => SlashCommandEnumValue[]} | 187 | * @returns {() => SlashCommandEnumValue[]} |
| 186 | */ | 188 | */ |
| 187 | tagsForChar: (mode = 'all') => (/** @type {import('./SlashCommandExecutor.js').SlashCommandExecutor} */ executor) => { | 189 | tagsForChar: (mode = 'all') => (/** @type {SlashCommandExecutor} */ executor) => { |
| 188 | // Try to see if we can find the char during execution to filter down the tags list some more. Otherwise take all tags. | 190 | // Try to see if we can find the char during execution to filter down the tags list some more. Otherwise take all tags. |
| 189 | const charName = executor.namedArgumentList.find(it => it.name == 'name')?.value; | 191 | const charName = executor.namedArgumentList.find(it => it.name == 'name')?.value; |
| 190 | if (charName instanceof SlashCommandClosure) throw new Error('Argument \'name\' does not support closures'); | 192 | if (charName instanceof SlashCommandClosure) throw new Error('Argument \'name\' does not support closures'); |
| @@ -202,13 +204,13 @@ export const commonEnumProviders = { | |||
| 202 | * @param {object} [options={}] - Optional arguments | 204 | * @param {object} [options={}] - Optional arguments |
| 203 | * @param {boolean} [options.allowIdAfter=false] - Whether to add an enum option for the new message id after the last message | 205 | * @param {boolean} [options.allowIdAfter=false] - Whether to add an enum option for the new message id after the last message |
| 204 | * @param {boolean} [options.allowVars=false] - Whether to add enum option for variable names | 206 | * @param {boolean} [options.allowVars=false] - Whether to add enum option for variable names |
| 205 | * @returns {() => SlashCommandEnumValue[]} | 207 | * @returns {(executor:SlashCommandExecutor, scope:SlashCommandScope) => SlashCommandEnumValue[]} |
| 206 | */ | 208 | */ |
| 207 | messages: ({ allowIdAfter = false, allowVars = false } = {}) => () => { | 209 | messages: ({ allowIdAfter = false, allowVars = false } = {}) => (_, scope) => { |
| 208 | return [ | 210 | return [ |
| 209 | ...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)), | 211 | ...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)), |
| 210 | ...allowIdAfter ? [new SlashCommandEnumValue(String(chat.length), '>> After Last Message >>', enumTypes.enum, '➕')] : [], | 212 | ...allowIdAfter ? [new SlashCommandEnumValue(String(chat.length), '>> After Last Message >>', enumTypes.enum, '➕')] : [], |
| 211 | ...allowVars ? commonEnumProviders.variables('all')() : [], | 213 | ...allowVars ? commonEnumProviders.variables('all')(_, scope) : [], |
| 212 | ]; | 214 | ]; |
| 213 | }, | 215 | }, |
| 214 | 216 | ||