[fix] fixed https://github.com/kwaroran/RisuAI/issues/122 and TTS quoted mode (#123)
Fixed : an error not showing up right away when creating a Group Chat an error when text had no quotes in TTS quote mode occurs TypeError: Cannot read properties of null (reading 'length')
This commit is contained in:
@@ -92,8 +92,6 @@ async function jpTrans(text:string) {
|
||||
|
||||
const url = `https://${host}/translate_a/single?client=gtx&sl=auto&tl=ja&dt=t&q=` + encodeURIComponent(text)
|
||||
|
||||
|
||||
|
||||
const f = await fetch(url, {
|
||||
|
||||
method: "GET",
|
||||
@@ -102,16 +100,17 @@ async function jpTrans(text:string) {
|
||||
|
||||
const res = await f.json()
|
||||
|
||||
|
||||
|
||||
if(typeof(res) === 'string'){
|
||||
|
||||
return res as unknown as string
|
||||
|
||||
|
||||
}
|
||||
|
||||
const result = res[0].map((s) => s[0]).filter(Boolean).join('');
|
||||
let result = ''
|
||||
|
||||
if (res[0]) {
|
||||
result = res[0].map((s) => s[0]).filter(Boolean).join('');
|
||||
}
|
||||
|
||||
return result
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user