Add simple error checking to chat cmd
All checks were successful
CI / CI (push) Successful in 1m25s

This commit is contained in:
SileNce5k 2025-04-30 23:38:46 +02:00
parent 8501be8882
commit c2e21659bf
Signed by: SileNce
GPG key ID: B0A142BB4291B204

View file

@ -36,7 +36,12 @@ module.exports = {
"max_tokens": 250
})
}).then(response => response.json()).then(data => {
answer = data.choices[0].message.content;
if(!data.error)
answer = data.choices[0].message.content;
else{
console.error(data.error.code);
answer = `Something went wrong. Got error code ${data.error.code}.`
}
}).catch(error => {
console.error(error);
});