mirror of
				https://github.com/SillyTavern/SillyTavern.git
				synced 2025-06-05 21:59:27 +02:00 
			
		
		
		
	Merge pull request #2244 from Wolfsblvt/rename-chat-command
Add /renamechat slash command
This commit is contained in:
		| @@ -8292,6 +8292,23 @@ async function doDeleteChat() { | ||||
|     $('#dialogue_popup_ok').trigger('click', { fromSlashCommand: true }); | ||||
| } | ||||
|  | ||||
| async function doRenameChat(_, chatName) { | ||||
|     if (!chatName) { | ||||
|         toastr.warning('Name must be provided as an argument to rename this chat.'); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     const currentChatName = getCurrentChatId(); | ||||
|     if (!currentChatName) { | ||||
|         toastr.warning('No chat selected that can be renamed.'); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     await renameChat(currentChatName, chatName); | ||||
|  | ||||
|     toastr.success(`Successfully renamed chat to: ${chatName}`); | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * Renames the currently selected chat. | ||||
|  * @param {string} oldFileName Old name of the chat (no JSONL extension) | ||||
| @@ -8583,6 +8600,16 @@ jQuery(async function () { | ||||
|         callback: doDeleteChat, | ||||
|         helpString: 'Deletes the current chat.', | ||||
|     })); | ||||
|     SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | ||||
|         name: 'renamechat', | ||||
|         callback: doRenameChat, | ||||
|         unnamedArgumentList: [ | ||||
|             new SlashCommandArgument( | ||||
|                 'new chat name', [ARGUMENT_TYPE.STRING], true, | ||||
|             ), | ||||
|         ], | ||||
|         helpString: 'Renames the current chat.', | ||||
|     })); | ||||
|     SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'getchatname', | ||||
|         callback: doGetChatName, | ||||
|         returns: 'chat file name', | ||||
| @@ -8592,6 +8619,11 @@ jQuery(async function () { | ||||
|         callback: doCloseChat, | ||||
|         helpString: 'Closes the current chat.', | ||||
|     })); | ||||
|     SlashCommandParser.addCommandObject(SlashCommand.fromProps({ | ||||
|         name: 'closechat', | ||||
|         callback: doCloseChat, | ||||
|         helpString: 'Closes the current chat.', | ||||
|     })); | ||||
|     SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'panels', | ||||
|         callback: doTogglePanels, | ||||
|         aliases: ['togglepanels'], | ||||
|   | ||||
		Reference in New Issue
	
	Block a user