From 3cff522147fc0dc982d63f81e1e5be4ff608739a Mon Sep 17 00:00:00 2001 From: supositware Date: Thu, 27 Aug 2020 15:16:19 +0200 Subject: [PATCH] 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 --- commands/utility/translate.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/commands/utility/translate.js b/commands/utility/translate.js index 024c51a9..104f32d7 100644 --- a/commands/utility/translate.js +++ b/commands/utility/translate.js @@ -46,8 +46,13 @@ class translateCommand extends Command { }).then((response) => { 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/`); - 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'); + } + let description = response.text[0]; let lang = response.detected.lang;