Refactor main slassh-commands into init func

cba2b54531293167424a7f4f17f3ba979cbe9a0a

Wolfsblvt <wolfsblvt@gmx.de>

2 files changed, +7 -5Showing whitespace changes
public/script.js+2 -1
@@ -159,7 +159,7 @@ import {
159159import { debounce_timeout } from './scripts/constants.js';
160160
161161import { ModuleWorkerWrapper, doDailyExtensionUpdatesCheck, extension_settings, getContext, loadExtensionSettings, renderExtensionTemplate, renderExtensionTemplateAsync, runGenerationInterceptors, saveMetadataDebounced, writeExtensionField } from './scripts/extensions.js';
162162import { COMMENT_NAME_DEFAULT, executeSlashCommands, executeSlashCommandsOnChatInput, getSlashCommandsHelp, initDefaultSlashCommands, isExecutingCommandsFromChatInput, pauseScriptExecution, processChatSlashCommands, registerSlashCommand, stopScriptExecution } from './scripts/slash-commands.js';
163163import {
164164 tag_map,
165165 tags,
@@ -911,6 +911,7 @@ async function firstLoadInit() {
911911 initKeyboard();
912912 initDynamicStyles();
913913 initTags();
914+ initDefaultSlashCommands();
914915 await getUserAvatars(true, user_avatar);
915916 await getCharacters();
916917 await getBackgrounds();
public/scripts/slash-commands.js+5 -4
@@ -38,13 +38,13 @@ import {
3838 system_message_types,
3939 this_chid,
4040} from '../script.js';
4141import { PARSER_FLAG, SlashCommandParser } from './slash-commands/SlashCommandParser.js';
4242import { SlashCommandParserError } from './slash-commands/SlashCommandParserError.js';
4343import { getMessageTimeStamp } from './RossAscends-mods.js';
4444import { hideChatMessageRange } from './chats.js';
4545import { extension_settings, getContext, saveMetadataDebounced } from './extensions.js';
4646import { getRegexedString, regex_placement } from './extensions/regex/engine.js';
4747import { findGroupMemberId, getGroupMembers, groups, is_group_generating, openGroupById, resetSelectedGroup, saveGroupChat, selected_group } from './group-chats.js';
4848import { chat_completion_sources, oai_settings, setupChatCompletionPromptManager } from './openai.js';
4949import { autoSelectPersona, retriggerFirstMessageOnEmptyChat, setPersonaLockState, togglePersonaLock, user_avatar } from './personas.js';
5050import { addEphemeralStoppingString, chat_styles, flushEphemeralStoppingStrings, power_user } from './power-user.js';
@@ -53,7 +53,6 @@ import { decodeTextTokens, getFriendlyTokenizerName, getTextTokens, getTokenCoun
5353import { debounce, delay, isFalseBoolean, isTrueBoolean, stringToRange, trimToEndSentence, trimToStartSentence, waitUntilCondition } from './utils.js';
5454import { registerVariableCommands, resolveVariable } from './variables.js';
5555import { background_settings } from './backgrounds.js';
56-import { SlashCommandScope } from './slash-commands/SlashCommandScope.js';
5756import { SlashCommandClosure } from './slash-commands/SlashCommandClosure.js';
5857import { SlashCommandClosureResult } from './slash-commands/SlashCommandClosureResult.js';
5958import { ARGUMENT_TYPE, SlashCommandArgument, SlashCommandNamedArgument } from './slash-commands/SlashCommandArgument.js';
@@ -75,6 +74,7 @@ export const parser = new SlashCommandParser();
7574const registerSlashCommand = SlashCommandParser.addCommand.bind(SlashCommandParser);
7675const getSlashCommandsHelp = parser.getHelpString.bind(parser);
7776
77+export function initDefaultSlashCommands() {
7878 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
7979 name: '?',
8080 callback: helpCommandCallback,
@@ -1387,6 +1387,7 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
13871387 }));
13881388
13891389 registerVariableCommands();
1390+}
13901391
13911392const NARRATOR_NAME_KEY = 'narrator_name';
13921393const NARRATOR_NAME_DEFAULT = 'System';