import { replacePickPlaceholders } from '@/services/pick' import { replaceRandomWordPlaceholders } from '@/services/randomWord' import { replaceShufflePlaceholders } from '@/services/shuffle' const replacers = [ replaceRandomWordPlaceholders, replacePickPlaceholders, replaceShufflePlaceholders ] const helpString = `
Replace the placeholders in the provided text.
Example:
` const initializeSlashCommands = () => { const { SlashCommandParser, SlashCommand, SlashCommandArgument } = SillyTavern.getContext() SlashCommandParser.addCommandObject( SlashCommand.fromProps({ name: 'randomReplace', aliases: ['replaceRandom'], unnamedArgumentList: [ SlashCommandArgument.fromProps({ description: 'The text to replace in placeholder format.', acceptsMultiple: false, typeList: ['string'], isRequired: true }) ], returns: 'The text with the placeholders replaced.', helpString, callback: (_, unnamedArgument) => { if (typeof unnamedArgument !== 'string') { return '' } let text = unnamedArgument for (const replacer of replacers) { text = replacer(text) } return text } }) ) } export default initializeSlashCommands