diff --git a/public/script.js b/public/script.js index b679b8c20..62dd825ad 100644 --- a/public/script.js +++ b/public/script.js @@ -216,6 +216,9 @@ import { currentUser, setUserControls } from './scripts/user.js'; import { callGenericPopup } from './scripts/popup.js'; import { renderTemplate, renderTemplateAsync } from './scripts/templates.js'; import { ScraperManager } from './scripts/scrapers.js'; +import { SlashCommandParser } from './scripts/slash-commands/SlashCommandParser.js'; +import { SlashCommand } from './scripts/slash-commands/SlashCommand.js'; +import { ARGUMENT_TYPE, SlashCommandArgument } from './scripts/slash-commands/SlashCommandArgument.js'; //exporting functions and vars for mods export { @@ -8601,19 +8604,137 @@ jQuery(async function () { toastr.success('Chat and settings saved.'); } - registerSlashCommand('dupe', DupeChar, [], '– duplicates the currently selected character', true, true); - registerSlashCommand('api', connectAPISlash, [], `(${Object.keys(CONNECT_API_MAP).join(', ')}) – connect to an API`, true, true); - registerSlashCommand('impersonate', doImpersonate, ['imp'], '[prompt] – calls an impersonation response, with an optional additional prompt', true, true); - registerSlashCommand('delchat', doDeleteChat, [], '– deletes the current chat', true, true); - registerSlashCommand('getchatname', doGetChatName, [], '– returns the name of the current chat file into the pipe', false, true); - registerSlashCommand('closechat', doCloseChat, [], '– closes the current chat', true, true); - registerSlashCommand('panels', doTogglePanels, ['togglepanels'], '– toggle UI panels on/off', true, true); - registerSlashCommand('forcesave', doForceSave, [], '– forces a save of the current chat and settings', true, true); - registerSlashCommand('instruct', selectInstructCallback, [], '(name) – selects instruct mode preset by name. Gets the current instruct if no name is provided', true, true); - registerSlashCommand('instruct-on', enableInstructCallback, [], '– enables instruct mode', true, true); - registerSlashCommand('instruct-off', disableInstructCallback, [], '– disables instruct mode', true, true); - registerSlashCommand('context', selectContextCallback, [], '(name) – selects context template by name. Gets the current template if no name is provided', true, true); - registerSlashCommand('chat-manager', () => $('#option_select_chat').trigger('click'), ['chat-history', 'manage-chats'], '– opens the chat manager for the current character/group', true, true); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'dupe', + callback: DupeChar, + helpString: 'Duplicates the currently selected character.', + })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'api', + callback: connectAPISlash, + namedArgumentList: [], + unnamedArgumentList: [ + new SlashCommandArgument( + 'API to connect to', + [ARGUMENT_TYPE.STRING], + true, + false, + null, + Object.keys(CONNECT_API_MAP), + ), + ], + helpString: ` +
${Object.keys(CONNECT_API_MAP).join(', ')}
+ /impersonate What is the meaning of life?
+ /instruct creative
+