Add a message for error code 408 (Maximum monthly translated text volume exceeded)

and log error when the response code is not 200

Signed-off-by: supositware <loic.bersier1@gmail.com>
This commit is contained in:
supositware 2020-08-27 15:16:19 +02:00
parent 06e7a98784
commit 3cff522147

View file

@ -46,8 +46,13 @@ class translateCommand extends Command {
}).then((response) => { }).then((response) => {
if (response.code == '502') if (response.code == '502')
return message.channel.send(`${response.message}, you probably didn't input the correct language code, you can check them here! https://tech.yandex.com/translate/doc/dg/concepts/api-overview-docpage/`); return message.channel.send(`${response.message}, you probably didn't input the correct language code, you can check them here! https://tech.yandex.com/translate/doc/dg/concepts/api-overview-docpage/`);
else if (response.code != '200') else if (response.code == '408')
return message.channel.send(response.message);
else if (response.code != '200') {
console.error(response);
return message.channel.send('An error has occurred'); return message.channel.send('An error has occurred');
}
let description = response.text[0]; let description = response.text[0];
let lang = response.detected.lang; let lang = response.detected.lang;