/rename-char slash command

- Rename char slash command (with optional parameters for silent and rename old chats)
- JSDoc fix for STscript named args in callbacks
This commit is contained in:
Wolfsblvt
2024-06-05 02:19:22 +02:00
parent 6bed373f0a
commit 858e5f2efb
3 changed files with 97 additions and 47 deletions

View File

@ -23,6 +23,7 @@ import {
name2,
reloadCurrentChat,
removeMacros,
renameCharacter,
saveChatConditional,
sendMessageAsUser,
sendSystemMessage,
@ -323,6 +324,29 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
helpString: 'Opens up a chat with the character or group by its name',
aliases: ['char'],
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'rename-char',
/** @param {{silent: string, renameChats: string}} options @param {string} name */
callback: async ({ silent = 'true', renameChats = null }, name) => {
const renamed = await renameCharacter(name, { silent: silent === 'true', renameChats: renameChats !== null ? renameChats === 'true' : null });
return String(renamed);
},
returns: 'true/false - Whether the rename was successful',
namedArgumentList: [
new SlashCommandNamedArgument(
'silent', 'Hide any blocking popups. (if false, the name is optional. If not supplied, a popup asking for it will appear)', [ARGUMENT_TYPE.BOOLEAN], false, false, 'true'
),
new SlashCommandNamedArgument(
'renameChats', 'Rename char in all previous chats', [ARGUMENT_TYPE.BOOLEAN], false, false, '<null>'
),
],
unnamedArgumentList: [
new SlashCommandArgument(
'new char name', [ARGUMENT_TYPE.STRING], true,
),
],
helpString: 'Renames the current character.'
}));
SlashCommandParser.addCommandObject(SlashCommand.fromProps({
name: 'sysgen',
callback: generateSystemMessage,