From fa06c432b5ed2681340a33511030b9662f9587d7 Mon Sep 17 00:00:00 2001 From: Ibrahim Ansari Date: Mon, 30 Mar 2020 20:28:40 +0530 Subject: [PATCH] Update Eris and fix /define errors. --- package.json | 2 +- server/bot/commands/api.ts | 7 +++++-- yarn.lock | 39 ++++++++++++++++---------------------- 3 files changed, 22 insertions(+), 26 deletions(-) diff --git a/package.json b/package.json index f4b944d..3dc867f 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "@material-ui/core": "^3.0.1", "@material-ui/icons": "^3.0.1", "apollo-boost": "^0.1.4", - "eris": "^0.11.1", + "eris": "^0.11.2", "graphql": "^14.0.2", "graphql-yoga": "^1.16.7", "isomorphic-unfetch": "^2.0.0", diff --git a/server/bot/commands/api.ts b/server/bot/commands/api.ts index 53ff8b2..5aa4233 100644 --- a/server/bot/commands/api.ts +++ b/server/bot/commands/api.ts @@ -466,13 +466,16 @@ export const handleDefine: Command = { `https://od-api.oxforddictionaries.com/api/v2/lemmas/en/${args.join(' ')}`, { headers } )).json() // If the word doesn't exist in the Oxford Dictionary.. - if (r.error === 'No entries were found for a given inflected word') { + if (r.error === 'No entries were found for a given inflected word' || ( + r.error && r.error.startsWith('No lemma was found') + )) { return 'Did you enter a valid word? 👾' } try { // Here we get the dictionary entries for the specified word. + const word = r.results[0].lexicalEntries[0].inflectionOf[0].id const { results } = await (await fetch( - `https://od-api.oxforddictionaries.com/api/v2/entries/en/${r.results[0].id}` + + `https://od-api.oxforddictionaries.com/api/v2/entries/en/${word}` + '?strictMatch=false&fields=definitions%2Cexamples', { headers } )).json() diff --git a/yarn.lock b/yarn.lock index d3bdadf..cb27d06 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1569,11 +1569,6 @@ async-each@^1.0.1: resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.2.tgz#8b8a7ca2a658f927e9f307d6d1a42f4199f0f735" integrity sha512-6xrbvN0MOBKSJDdonmSSz2OwFSgxRaVtBDes26mj9KIGtDo+g9xosFRSC+i1gQh2oAN/tQ62AI/pGZGQjVOiRg== -async-limiter@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.1.tgz#dd379e94f0db8310b08291f9d64c3209766617fd" - integrity sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ== - async-limiter@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8" @@ -2731,15 +2726,15 @@ enhanced-resolve@^4.1.0: memory-fs "^0.4.0" tapable "^1.0.0" -eris@^0.11.1: - version "0.11.1" - resolved "https://registry.yarnpkg.com/eris/-/eris-0.11.1.tgz#b4c9ba9645c5eef9f9922c2be3c41395a3121a61" - integrity sha512-Ct32iXjESOnmklxZCEA281BQsTlAsS9xzQkbGlnvzXshCjBptWJ5h8Oxbu67ui1DirsYs0WipB8EBC9ITQ5ZQA== +eris@^0.11.2: + version "0.11.2" + resolved "https://registry.yarnpkg.com/eris/-/eris-0.11.2.tgz#a4adad72d795d64d71a74833ccf5adc4db0ad8c0" + integrity sha512-OhccRcxrPiNUylTamrjIbZM6itKMLjNrwLIXGvNwQZj4CRVOOz9eUVIqOJULB713x1ezw7HoC8AEsnsMNUneDA== dependencies: - ws "^7.1.2" + ws "^7.2.1" optionalDependencies: - opusscript "^0.0.4" - tweetnacl "^1.0.0" + opusscript "^0.0.7" + tweetnacl "^1.0.1" errno@^0.1.2, errno@^0.1.3, errno@^0.1.4, errno@~0.1.7: version "0.1.7" @@ -5208,10 +5203,10 @@ optionator@^0.8.2: type-check "~0.3.2" wordwrap "~1.0.0" -opusscript@^0.0.4: - version "0.0.4" - resolved "https://registry.yarnpkg.com/opusscript/-/opusscript-0.0.4.tgz#c718edcfdcd2a1f55fadb266dd07268d4a46afde" - integrity sha512-bEPZFE2lhUJYQD5yfTFO4RhbRZ937x6hRwBC1YoGacT35bwDVwKFP1+amU8NYfZL/v4EU7ZTU3INTqzYAnuP7Q== +opusscript@^0.0.7: + version "0.0.7" + resolved "https://registry.yarnpkg.com/opusscript/-/opusscript-0.0.7.tgz#7dd7ec55b302d26bf588e6fc3feb090b8c7da856" + integrity sha512-DcBadTdYTUuH9zQtepsLjQn4Ll6rs3dmeFvN+SD0ThPnxRBRm/WC1zXWPg+wgAJimB784gdZvUMA57gDP7FdVg== os-browserify@^0.3.0: version "0.3.0" @@ -6860,7 +6855,7 @@ tty-browserify@0.0.0: resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" integrity sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY= -tweetnacl@^1.0.0: +tweetnacl@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.1.tgz#2594d42da73cd036bd0d2a54683dd35a6b55ca17" integrity sha512-kcoMoKTPYnoeS50tzoqjPY3Uv9axeuuFAZY9M/9zFnhoVvRfxz9K29IMPD7jGmt2c8SW7i3gT9WqDl2+nV7p4A== @@ -7289,12 +7284,10 @@ ws@^5.2.0: dependencies: async-limiter "~1.0.0" -ws@^7.1.2: - version "7.2.0" - resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.0.tgz#422eda8c02a4b5dba7744ba66eebbd84bcef0ec7" - integrity sha512-+SqNqFbwTm/0DC18KYzIsMTnEWpLwJsiasW/O17la4iDRRIO9uaHbvKiAS3AHgTiuuWerK/brj4O6MYZkei9xg== - dependencies: - async-limiter "^1.0.0" +ws@^7.2.1: + version "7.2.1" + resolved "https://registry.yarnpkg.com/ws/-/ws-7.2.1.tgz#03ed52423cd744084b2cf42ed197c8b65a936b8e" + integrity sha512-sucePNSafamSKoOqoNfBd8V0StlkzJKL2ZAhGQinCfNQ+oacw+Pk7lcdAElecBF2VkLNZRiIb5Oi1Q5lVUVt2A== xdg-basedir@^3.0.0: version "3.0.0"