소스 검색

Merge pull request #6424 from Peter-De-Ath/add-user-name-slash-prompt

feat: add user_name to slash prompt template
Timothy Jaeryang Baek 6 달 전
부모
커밋
04babeb45a
1개의 변경된 파일7개의 추가작업 그리고 1개의 파일을 삭제
  1. 7 1
      src/lib/components/chat/MessageInput/Commands/Prompts.svelte

+ 7 - 1
src/lib/components/chat/MessageInput/Commands/Prompts.svelte

@@ -1,5 +1,5 @@
 <script lang="ts">
 <script lang="ts">
-	import { prompts } from '$lib/stores';
+	import { prompts, user } from '$lib/stores';
 	import {
 	import {
 		findWordIndices,
 		findWordIndices,
 		getUserPosition,
 		getUserPosition,
@@ -78,6 +78,12 @@
 			text = text.replaceAll('{{USER_LOCATION}}', String(location));
 			text = text.replaceAll('{{USER_LOCATION}}', String(location));
 		}
 		}
 
 
+		if (command.content.includes('{{USER_NAME}}')) {
+			console.log($user);
+			const name = $user.name || 'User';
+			text = text.replaceAll('{{USER_NAME}}', name);
+		}
+
 		if (command.content.includes('{{USER_LANGUAGE}}')) {
 		if (command.content.includes('{{USER_LANGUAGE}}')) {
 			const language = localStorage.getItem('locale') || 'en-US';
 			const language = localStorage.getItem('locale') || 'en-US';
 			text = text.replaceAll('{{USER_LANGUAGE}}', language);
 			text = text.replaceAll('{{USER_LANGUAGE}}', language);