Small changes to /rename-char

This commit is contained in:
Wolfsblvt 2024-06-05 20:24:50 +02:00
parent 858e5f2efb
commit f04bbdf112
2 changed files with 6 additions and 2 deletions

View File

@ -5436,6 +5436,10 @@ export async function renameCharacter(name = null, { silent = false, renameChats
toastr.warning('No character name provided.', 'Rename Character');
return false;
}
if (this_chid === undefined) {
toastr.warning('No character selected.', 'Rename Character');
return false;
}
const oldAvatar = characters[this_chid].avatar;
const newValue = name || await callPopup('<h3>New name:</h3>', 'input', characters[this_chid].name);

View File

@ -328,7 +328,7 @@ 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 });
const renamed = await renameCharacter(name, { silent: isTrueBoolean(silent), renameChats: renameChats !== null ? isTrueBoolean(renameChats) : null });
return String(renamed);
},
returns: 'true/false - Whether the rename was successful',
@ -337,7 +337,7 @@ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
'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>'
'chats', 'Rename char in all previous chats', [ARGUMENT_TYPE.BOOLEAN], false, false, '<null>'
),
],
unnamedArgumentList: [