didn't know you can just put auto

This commit is contained in:
Joonas 2023-02-25 15:50:39 +02:00
parent 0bdab37f2e
commit ba2f3e8f92
1 changed files with 5 additions and 7 deletions

View File

@ -7,17 +7,15 @@ const command = {
if (!splitted[2] || !splitted[3]) { if (!splitted[2] || !splitted[3]) {
await client.say( await client.say(
msg.channelName, msg.channelName,
`${msg.displayName}, needed <source country code> <target country code> <text to be translated>` `${msg.displayName}, needed <target country code> <text to be translated>`
); );
return; return;
} }
const data = await fetch( const data = await fetch(
`https://lingva.ml/api/v1/${encodeURIComponent( `https://lingva.ml/api/v1/auto/${encodeURIComponent(
splitted[2] splitted[2]
)}/${encodeURIComponent(splitted[3])}/${encodeURIComponent( )}/${encodeURIComponent(splitted.slice(3).join(" "))}`
splitted.slice(4).join(" ")
)}`
) )
.then((res) => res.json()) .then((res) => res.json())
.catch((err) => console.error("Error with translating: " + err.message)); .catch((err) => console.error("Error with translating: " + err.message));
@ -34,8 +32,8 @@ const command = {
await client.say( await client.say(
msg.channelName, msg.channelName,
`${msg.displayName}, Translation of ${splitted `${msg.displayName}, Translation of ${splitted
.slice(4) .slice(3)
.join(" ")} to lang ${splitted[3]}: '${data.translation}'` .join(" ")} to lang ${splitted[2]}: '${data.translation}'`
); );
}, },
}; };